Skip to content

Commit

Permalink
Adds compatability for Opentracing 1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Kay committed Jun 27, 2018
1 parent a74e991 commit ec4c666
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ workspace(name = "com_github_rnburn_zipkin_opentracing")
git_repository(
name = "io_opentracing_cpp",
remote = "https://github.com/opentracing/opentracing-cpp",
commit = "44e74489586550c388cca92f3ece187b3f1bf5d5",
commit = "ac50154a7713877f877981c33c3375003b6ebfe1",
)

# TODO: Fill in libcurl dependency
2 changes: 1 addition & 1 deletion ci/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ workspace(name = "com_github_rnburn_zipkin_opentracing")
git_repository(
name = "io_opentracing_cpp",
remote = "https://github.com/opentracing/opentracing-cpp",
commit = "44e74489586550c388cca92f3ece187b3f1bf5d5",
commit = "ac50154a7713877f877981c33c3375003b6ebfe1",
)

new_local_repository(
Expand Down
2 changes: 1 addition & 1 deletion ci/build_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apt-get install --no-install-recommends --no-install-suggests -y \
git \
ca-certificates

export OPENTRACING_VERSION=1.4.0
export OPENTRACING_VERSION=1.5.0

# Compile for a portable cpu architecture
export CFLAGS="-march=x86-64"
Expand Down
40 changes: 30 additions & 10 deletions zipkin_opentracing/src/dynamic_load.cc
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
#include "tracer_factory.h"
#include <cstring>
#include <cstdio>
#include <exception>
#include <opentracing/dynamic_load.h>

int OpenTracingMakeTracerFactory(const char *opentracing_version,
const void **error_category,
void **tracer_factory) {
if (std::strcmp(opentracing_version, OPENTRACING_VERSION) != 0) {

static int OpenTracingMakeTracerFactoryFunction(
const char* opentracing_version, const char* opentracing_abi_version,
const void** error_category, void* error_message,
void** tracer_factory) try {
if (opentracing_version == nullptr || opentracing_abi_version == nullptr ||
error_message == nullptr || error_category == nullptr ||
tracer_factory == nullptr) {
fprintf(stderr,
"`opentracing_version`, `opentracing_abi_version`, "
"`error_message`, `error_category`, and `tracer_factory` must be "
"non-null.\n");
std::terminate();
}

if (std::strcmp(opentracing_abi_version, OPENTRACING_ABI_VERSION) != 0) {
*error_category =
static_cast<const void *>(&opentracing::dynamic_load_error_category());
static_cast<const void*>(&opentracing::dynamic_load_error_category());
auto& message = *static_cast<std::string*>(error_message);
message =
"incompatible OpenTracing ABI versions; "
"expected " OPENTRACING_ABI_VERSION " but got ";
message.append(opentracing_abi_version);
return opentracing::incompatible_library_versions_error.value();
}

*tracer_factory = new (std::nothrow) zipkin::OtTracerFactory{};
if (tracer_factory == nullptr) {
*error_category = static_cast<const void *>(&std::generic_category());
return static_cast<int>(std::errc::not_enough_memory);
}
*tracer_factory = new zipkin::OtTracerFactory{};

return 0;
} catch (const std::bad_alloc&) {
*error_category = static_cast<const void*>(&std::generic_category());
return static_cast<int>(std::errc::not_enough_memory);
}

OPENTRACING_DECLARE_IMPL_FACTORY(OpenTracingMakeTracerFactoryFunction)

0 comments on commit ec4c666

Please sign in to comment.