Skip to content

Commit

Permalink
Add Bazel build, fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
chusitoo committed Jan 8, 2023
1 parent 697c402 commit 2d2adf3
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 2 deletions.
11 changes: 11 additions & 0 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ def opentelemetry_cpp_deps():
],
)

# Opentracing
maybe(
http_archive,
name = "com_github_opentracing",
sha256 = "5b170042da4d1c4c231df6594da120875429d5231e9baa5179822ee8d1054ac3",
strip_prefix = "opentracing-cpp-1.6.0",
urls = [
"https://github.com/opentracing/opentracing-cpp/archive/refs/tags/v1.6.0.tar.gz",
],
)

# boost headers from vcpkg
maybe(
native.new_local_repository,
Expand Down
102 changes: 102 additions & 0 deletions opentracing-shim/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "opentracing_shim",
srcs = [
"src/span_context_shim.cc",
"src/span_shim.cc",
"src/tracer_shim.cc",
],
hdrs = [
"include/opentelemetry/opentracingshim/propagation.h",
"include/opentelemetry/opentracingshim/shim_utils.h",
"include/opentelemetry/opentracingshim/span_context_shim.h",
"include/opentelemetry/opentracingshim/span_shim.h",
"include/opentelemetry/opentracingshim/tracer_shim.h",
],
strip_include_prefix = "include",
tags = ["opentracing"],
deps = [
"//api",
"@com_github_opentracing//:opentracing",
],
)

cc_test(
name = "propagation_test",
srcs = [
"test/propagation_test.cc",
"test/shim_mocks.h",
],
tags = [
"opentracing_shim",
"test",
],
deps = [
":opentracing_shim",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "shim_utils_test",
srcs = [
"test/shim_utils_test.cc",
"test/shim_mocks.h",
],
tags = [
"opentracing_shim",
"test",
],
deps = [
":opentracing_shim",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "span_shim_test",
srcs = [
"test/span_shim_test.cc",
"test/shim_mocks.h",
],
tags = [
"opentracing_shim",
"test",
],
deps = [
":opentracing_shim",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "span_context_shim_test",
srcs = [
"test/span_context_shim_test.cc",
],
tags = [
"opentracing_shim",
"test",
],
deps = [
":opentracing_shim",
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "tracer_shim_test",
srcs = [
"test/tracer_shim_test.cc",
"test/shim_mocks.h",
],
tags = [
"opentracing_shim",
"test",
],
deps = [
":opentracing_shim",
"@com_google_googletest//:gtest_main",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline opentelemetry::common::AttributeValue attributeFromValue(const ope
AttributeValue operator()(double v) { return v; }
AttributeValue operator()(int64_t v) { return v; }
AttributeValue operator()(uint64_t v) { return v; }
AttributeValue operator()(std::string v) { return v.c_str(); }
AttributeValue operator()(const std::string& v) { return v.c_str(); }
AttributeValue operator()(opentracing::string_view v) { return nostd::string_view{v.data()}; }
AttributeValue operator()(std::nullptr_t) { return nostd::string_view{}; }
AttributeValue operator()(const char* v) { return v; }
Expand All @@ -55,7 +55,7 @@ static inline std::string stringFromValue(const opentracing::Value& value)
std::string operator()(double v) { return std::to_string(v); }
std::string operator()(int64_t v) { return std::to_string(v); }
std::string operator()(uint64_t v) { return std::to_string(v); }
std::string operator()(std::string v) { return v; }
std::string operator()(const std::string& v) { return v; }
std::string operator()(opentracing::string_view v) { return std::string{v.data()}; }
std::string operator()(std::nullptr_t) { return std::string{}; }
std::string operator()(const char* v) { return std::string{v}; }
Expand Down

0 comments on commit 2d2adf3

Please sign in to comment.