Skip to content

Commit 7c90e1b

Browse files
authored
Merge branch 'main' into add-scope-config
2 parents f0e9df6 + d693e95 commit 7c90e1b

File tree

69 files changed

+1782
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1782
-113
lines changed

CHANGELOG.md

+63
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,69 @@ Increment the:
2727
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
2828
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)
2929

30+
* [EXPORTER] Fix throw in OtlpGrpcMetricExporter with shared grpc client
31+
[#3243](https://github.com/open-telemetry/opentelemetry-cpp/pull/3243)
32+
33+
* [SDK] Better control of threads executed by opentelemetry-cpp
34+
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)
35+
36+
New features:
37+
38+
* [SDK] Better control of threads executed by opentelemetry-cpp
39+
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)
40+
41+
* This feature provides a way for applications,
42+
when configuring the SDK and exporters,
43+
to participate in the execution path
44+
of internal opentelemetry-cpp threads.
45+
46+
* The opentelemetry-cpp library provides the following:
47+
48+
* a new ThreadInstrumentation interface,
49+
* new runtime options structures, to optionally configure the SDK:
50+
* BatchSpanProcessorRuntimeOptions
51+
* PeriodicExportingMetricReaderRuntimeOptions
52+
* BatchLogRecordProcessorRuntimeOptions
53+
* new runtime options structures,
54+
to optionally configure the OTLP HTTP exporters:
55+
* OtlpHttpExporterRuntimeOptions
56+
* OtlpHttpMetricExporterRuntimeOptions
57+
* OtlpHttpLogRecordExporterRuntimeOptions
58+
* new ThreadInstrumentation parameters,
59+
to optionally configure the CURL HttpClient
60+
* new runtime options structures,
61+
to optionally configure the OTLP FILE exporters:
62+
* OtlpFileExporterRuntimeOptions
63+
* OtlpFileMetricExporterRuntimeOptions
64+
* OtlpFileLogRecordExporterRuntimeOptions
65+
* new runtime options structure,
66+
to optionally configure the OTLP FILE client:
67+
* OtlpFileClientRuntimeOptions
68+
69+
* Using the optional runtime options structures,
70+
an application can subclass the ThreadInstrumentation interface,
71+
and be notified of specific events of interest during the execution
72+
of an internal opentelemetry-cpp thread.
73+
74+
* This allows an application to call, for example:
75+
76+
* pthread_setaffinity_np(), for better performances,
77+
* setns(), to control the network namespace used by HTTP CURL connections
78+
* pthread_setname_np(), for better observability from the operating system
79+
* many more specific apis, as needed
80+
81+
* See the documentation for ThreadInstrumentation for details.
82+
83+
* A new example program, example_otlp_instrumented_http,
84+
shows how to use the feature,
85+
and add application logic in the thread execution code path.
86+
87+
* Note that this feature is experimental,
88+
protected by a WITH_THREAD_INSTRUMENTATION_PREVIEW
89+
flag in CMake. Various runtime options structures,
90+
as well as the thread instrumentation interface,
91+
may change without notice before this feature is declared stable.
92+
3093
## [1.18 2024-11-25]
3194

3295
* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ option(WITH_ASYNC_EXPORT_PREVIEW "Whether to enable async export" OFF)
300300
option(WITH_METRICS_EXEMPLAR_PREVIEW
301301
"Whether to enable exemplar within metrics" OFF)
302302

303+
# Experimental, so behind feature flag by default
304+
option(WITH_THREAD_INSTRUMENTATION_PREVIEW
305+
"Whether to enable thread instrumentation" OFF)
306+
303307
option(OPENTELEMETRY_SKIP_DYNAMIC_LOADING_TESTS
304308
"Whether to build test libraries that are always linked as shared libs"
305309
OFF)

api/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ if(WITH_METRICS_EXEMPLAR_PREVIEW)
126126
INTERFACE ENABLE_METRICS_EXEMPLAR_PREVIEW)
127127
endif()
128128

129+
if(WITH_THREAD_INSTRUMENTATION_PREVIEW)
130+
target_compile_definitions(opentelemetry_api
131+
INTERFACE ENABLE_THREAD_INSTRUMENTATION_PREVIEW)
132+
endif()
133+
129134
if(WITH_OTLP_HTTP_COMPRESSION)
130135
target_compile_definitions(opentelemetry_api
131136
INTERFACE ENABLE_OTLP_COMPRESSION_PREVIEW)

ci/do_ci.sh

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ elif [[ "$1" == "cmake.maintainer.sync.test" ]]; then
131131
-DOTELCPP_MAINTAINER_MODE=ON \
132132
-DWITH_NO_DEPRECATED_CODE=ON \
133133
-DWITH_OTLP_HTTP_COMPRESSION=ON \
134+
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
134135
${IWYU} \
135136
"${SRC_DIR}"
136137
eval "$MAKE_COMMAND"
@@ -153,6 +154,7 @@ elif [[ "$1" == "cmake.maintainer.async.test" ]]; then
153154
-DOTELCPP_MAINTAINER_MODE=ON \
154155
-DWITH_NO_DEPRECATED_CODE=ON \
155156
-DWITH_OTLP_HTTP_COMPRESSION=ON \
157+
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
156158
${IWYU} \
157159
"${SRC_DIR}"
158160
eval "$MAKE_COMMAND"
@@ -176,6 +178,7 @@ elif [[ "$1" == "cmake.maintainer.cpp11.async.test" ]]; then
176178
-DOTELCPP_MAINTAINER_MODE=ON \
177179
-DWITH_NO_DEPRECATED_CODE=ON \
178180
-DWITH_OTLP_HTTP_COMPRESSION=ON \
181+
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
179182
"${SRC_DIR}"
180183
make -k -j $(nproc)
181184
make test
@@ -199,6 +202,7 @@ elif [[ "$1" == "cmake.maintainer.abiv2.test" ]]; then
199202
-DWITH_ABI_VERSION_1=OFF \
200203
-DWITH_ABI_VERSION_2=ON \
201204
-DWITH_OTLP_HTTP_COMPRESSION=ON \
205+
-DWITH_THREAD_INSTRUMENTATION_PREVIEW=ON \
202206
${IWYU} \
203207
"${SRC_DIR}"
204208
eval "$MAKE_COMMAND"

examples/otlp/BUILD

+22
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,25 @@ cc_binary(
168168
"//sdk/src/metrics",
169169
],
170170
)
171+
172+
cc_binary(
173+
name = "example_otlp_instrumented_http",
174+
srcs = [
175+
"http_instrumented_main.cc",
176+
],
177+
tags = [
178+
"examples",
179+
"otlp",
180+
"otlp_http",
181+
],
182+
deps = [
183+
"//api",
184+
"//examples/common/logs_foo_library:common_logs_foo_library",
185+
"//examples/common/metrics_foo_library:common_metrics_foo_library",
186+
"//exporters/otlp:otlp_http_exporter",
187+
"//exporters/otlp:otlp_http_log_record_exporter",
188+
"//exporters/otlp:otlp_http_metric_exporter",
189+
"//sdk/src/metrics",
190+
"//sdk/src/trace",
191+
],
192+
)

examples/otlp/CMakeLists.txt

+23
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,29 @@ if(WITH_OTLP_HTTP)
9999
opentelemetry_exporter_otlp_http_log)
100100
endif()
101101

102+
# ALL, instrumented
103+
104+
add_executable(example_otlp_instrumented_http http_instrumented_main.cc)
105+
106+
# Note: common_logs_foo_library provide traces and logs
107+
target_link_libraries(
108+
example_otlp_instrumented_http ${CMAKE_THREAD_LIBS_INIT}
109+
common_metrics_foo_library common_logs_foo_library)
110+
111+
if(DEFINED OPENTELEMETRY_BUILD_DLL)
112+
target_link_libraries(example_otlp_instrumented_http opentelemetry_cpp
113+
opentelemetry_common)
114+
else()
115+
target_link_libraries(
116+
example_otlp_instrumented_http
117+
opentelemetry_trace
118+
opentelemetry_metrics
119+
opentelemetry_logs
120+
opentelemetry_exporter_otlp_http
121+
opentelemetry_exporter_otlp_http_metric
122+
opentelemetry_exporter_otlp_http_log)
123+
endif()
124+
102125
endif()
103126

104127
if(WITH_OTLP_FILE)

0 commit comments

Comments
 (0)