Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK] Better control of threads executed by opentelemetry-cpp #3175

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3975855
[POC] Better control of threads executed by opentelemetry-cpp
marcalff Nov 26, 2024
b594ee0
warning cleanup
marcalff Nov 27, 2024
88bd0bf
cleanup initializers in structs
marcalff Nov 27, 2024
abb9674
typo
marcalff Nov 27, 2024
0214d95
Merge branch 'main' into feat_thread_instrumentation
marcalff Nov 27, 2024
24816a8
cleanup
marcalff Nov 27, 2024
d5f1075
Fix curl thread detach
marcalff Nov 27, 2024
eedde5c
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 9, 2024
809ade7
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 17, 2024
2d223d8
Moved runtime options to a dedicated structure.
marcalff Dec 17, 2024
9ea4223
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 17, 2024
738f95f
cleanup
marcalff Dec 17, 2024
8650478
bazel build
marcalff Dec 17, 2024
b8dbe39
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 18, 2024
bae36b8
Added example
marcalff Dec 18, 2024
941dd20
fix bazel
marcalff Dec 18, 2024
85be1ca
cleanup
marcalff Dec 18, 2024
a2fcfc9
Fixed bad merge
marcalff Dec 18, 2024
aec98dc
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 18, 2024
fb3d60b
Add changelog.
marcalff Dec 18, 2024
715b76d
cleanup
marcalff Dec 18, 2024
df04b03
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 19, 2024
e9b09a0
Instrumented the OTLP FILE exporter.
marcalff Dec 19, 2024
22048a8
fix bazel
marcalff Dec 19, 2024
943f079
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 19, 2024
bf4e9ff
iwyu
marcalff Dec 19, 2024
564fbad
Document OTLP FILE in changelog
marcalff Dec 19, 2024
3b6699f
Merge branch 'main' into feat_thread_instrumentation
marcalff Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,60 @@ Increment the:
* [EXPORTER] Fix scope attributes missing from otlp traces metrics
[#3185](https://github.com/open-telemetry/opentelemetry-cpp/pull/3185)

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

New features:

* [SDK] Better control of threads executed by opentelemetry-cpp
[#3175](https://github.com/open-telemetry/opentelemetry-cpp/pull/3175)

* This feature provides a way for applications,
when configuring the SDK and exporters,
to participate in the execution path
of internal opentelemetry-cpp threads.

* The opentelemetry-cpp library provides the following:

* a new ThreadInstrumentation interface,
* new runtime options structures, to optionally configure the SDK:
* BatchSpanProcessorRuntimeOptions
* PeriodicExportingMetricReaderRuntimeOptions
* BatchLogRecordProcessorRuntimeOptions
* new runtime options structures,
to optionally configure the OTLP HTTP exporters:
* OtlpHttpExporterRuntimeOptions
* OtlpHttpMetricExporterRuntimeOptions
* OtlpHttpLogRecordExporterRuntimeOptions
* new ThreadInstrumentation parameters,
to optionally configure the CURL HttpClient
* new runtime options structures,
to optionally configure the OTLP FILE exporters:
* OtlpFileExporterRuntimeOptions
* OtlpFileMetricExporterRuntimeOptions
* OtlpFileLogRecordExporterRuntimeOptions
* new runtime options structure,
to optionally configure the OTLP FILE client:
* OtlpFileClientRuntimeOptions

* Using the optional runtime options structures,
an application can subclass the ThreadInstrumentation interface,
and be notified of specific events of interest during the execution
of an internal opentelemetry-cpp thread.

* This allows an application to call, for example:

* pthread_setaffinity_np(), for better performances,
* setns(), to control the network namespace used by HTTP CURL connections
* pthread_setname_np(), for better observability from the operating system
* many more specific apis, as needed

* See the documentation for ThreadInstrumentation for details.

* A new example program, example_otlp_instrumented_http,
shows how to use the feature,
and add application logic in the thread execution code path.

## [1.18 2024-11-25]

* [EXPORTER] Fix crash in ElasticsearchLogRecordExporter
Expand Down
22 changes: 22 additions & 0 deletions examples/otlp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,25 @@ cc_binary(
"//sdk/src/metrics",
],
)

cc_binary(
name = "example_otlp_instrumented_http",
srcs = [
"http_instrumented_main.cc",
],
tags = [
"examples",
"otlp",
"otlp_http",
],
deps = [
"//api",
"//examples/common/logs_foo_library:common_logs_foo_library",
"//examples/common/metrics_foo_library:common_metrics_foo_library",
"//exporters/otlp:otlp_http_exporter",
"//exporters/otlp:otlp_http_log_record_exporter",
"//exporters/otlp:otlp_http_metric_exporter",
"//sdk/src/metrics",
"//sdk/src/trace",
],
)
23 changes: 23 additions & 0 deletions examples/otlp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@ if(WITH_OTLP_HTTP)
opentelemetry_exporter_otlp_http_log)
endif()

# ALL, instrumented

add_executable(example_otlp_instrumented_http http_instrumented_main.cc)

# Note: common_logs_foo_library provide traces and logs
target_link_libraries(
example_otlp_instrumented_http ${CMAKE_THREAD_LIBS_INIT}
common_metrics_foo_library common_logs_foo_library)

if(DEFINED OPENTELEMETRY_BUILD_DLL)
target_link_libraries(example_otlp_instrumented_http opentelemetry_cpp
opentelemetry_common)
else()
target_link_libraries(
example_otlp_instrumented_http
opentelemetry_trace
opentelemetry_metrics
opentelemetry_logs
opentelemetry_exporter_otlp_http
opentelemetry_exporter_otlp_http_metric
opentelemetry_exporter_otlp_http_log)
endif()

endif()

if(WITH_OTLP_FILE)
Expand Down
Loading
Loading