-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,392 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
cc_library( | ||
name = "opentracing_shim", | ||
srcs = [ | ||
"src/shim_utils.cc", | ||
"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_mocks.h", | ||
"test/shim_utils_test.cc", | ||
], | ||
tags = [ | ||
"opentracing_shim", | ||
"test", | ||
], | ||
deps = [ | ||
":opentracing_shim", | ||
"@com_google_googletest//:gtest_main", | ||
], | ||
) | ||
|
||
cc_test( | ||
name = "span_shim_test", | ||
srcs = [ | ||
"test/shim_mocks.h", | ||
"test/span_shim_test.cc", | ||
], | ||
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/shim_mocks.h", | ||
"test/tracer_shim_test.cc", | ||
], | ||
tags = [ | ||
"opentracing_shim", | ||
"test", | ||
], | ||
deps = [ | ||
":opentracing_shim", | ||
"@com_google_googletest//:gtest_main", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set(this_target opentelemetry_opentracing_shim) | ||
|
||
add_library(${this_target} src/shim_utils.cc src/span_shim.cc | ||
src/span_context_shim.cc src/tracer_shim.cc) | ||
|
||
set_target_properties(${this_target} PROPERTIES EXPORT_NAME opentracing_shim) | ||
|
||
target_include_directories( | ||
${this_target} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>" | ||
"$<INSTALL_INTERFACE:include>") | ||
|
||
if(OPENTRACING_DIR) | ||
include_directories( | ||
"${CMAKE_BINARY_DIR}/${OPENTRACING_DIR}/include" | ||
"${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/include" | ||
"${CMAKE_SOURCE_DIR}/${OPENTRACING_DIR}/3rd_party/include") | ||
target_link_libraries(${this_target} opentelemetry_api opentracing) | ||
else() | ||
target_link_libraries(${this_target} opentelemetry_api | ||
OpenTracing::opentracing) | ||
endif() | ||
|
||
install( | ||
TARGETS ${this_target} | ||
EXPORT "${PROJECT_NAME}-target" | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
||
install( | ||
DIRECTORY include/opentelemetry/opentracingshim | ||
DESTINATION include/opentelemetry | ||
FILES_MATCHING | ||
PATTERN "*.h") | ||
|
||
if(BUILD_TESTING) | ||
foreach(testname propagation_test shim_utils_test span_shim_test | ||
span_context_shim_test tracer_shim_test) | ||
|
||
add_executable(${testname} "test/${testname}.cc") | ||
|
||
if(OPENTRACING_DIR) | ||
target_link_libraries( | ||
${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} | ||
opentelemetry_api opentelemetry_opentracing_shim opentracing) | ||
else() | ||
target_link_libraries( | ||
${testname} ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} | ||
opentelemetry_api opentelemetry_opentracing_shim | ||
OpenTracing::opentracing) | ||
endif() | ||
|
||
gtest_add_tests( | ||
TARGET ${testname} | ||
TEST_PREFIX opentracing_shim. | ||
TEST_LIST ${testname}) | ||
endforeach() | ||
endif() # BUILD_TESTING |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# OpenTracing Shim | ||
|
||
[![Apache License][license-image]][license-image] | ||
|
||
The OpenTracing shim is a bridge layer from OpenTelemetry to the OpenTracing API. | ||
It takes an OpenTelemetry Tracer and exposes it as an implementation compatible with | ||
that of an OpenTracing Tracer. | ||
|
||
## Usage | ||
|
||
Use the TracerShim wherever you initialize your OpenTracing tracers. | ||
There are 2 ways to expose an OpenTracing Tracer: | ||
|
||
1. From the global OpenTelemetry configuration: | ||
|
||
```cpp | ||
auto tracer_shim = TracerShim::createTracerShim(); | ||
``` | ||
|
||
1. From a provided OpenTelemetry Tracer instance: | ||
|
||
```cpp | ||
auto tracer_shim = TracerShim::createTracerShim(tracer); | ||
``` | ||
|
||
Optionally, one can also specify the propagators to be used for the OpenTracing `TextMap` | ||
and `HttpHeaders` formats: | ||
|
||
```cpp | ||
OpenTracingPropagators propagators{ | ||
.text_map = nostd::shared_ptr<TextMapPropagator>(new CustomTextMap()), | ||
.http_headers = nostd::shared_ptr<TextMapPropagator>(new trace::propagation::HttpTraceContext()) | ||
}; | ||
|
||
auto tracer_shim = TracerShim::createTracerShim(tracer, propagators); | ||
``` | ||
|
||
If propagators are not specified, OpenTelemetry's global propagator will be used. | ||
|
||
## License | ||
|
||
Apache 2.0 - See [LICENSE][license-url] for more information. | ||
|
||
## Useful links | ||
|
||
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] | ||
|
||
[discussions-url]: https://github.com/open-telemetry/opentelemetry-cpp/discussions | ||
[license-url]: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/LICENSE | ||
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat |
Oops, something went wrong.