Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
75137db
[SDK] Support dynamic TracerConfigurator updates
dbarker May 7, 2026
26c9092
Merge branch 'main' into feature_tracer_configurator_updates
dbarker May 7, 2026
01d6d07
Merge branch 'main' into feature_tracer_configurator_updates
lalitb May 8, 2026
6ee3f69
address review feedback
dbarker May 13, 2026
e7398ea
Merge branch 'main' into feature_tracer_configurator_updates
dbarker May 13, 2026
5e79961
add changelog entry
dbarker May 13, 2026
7bf4ca3
Merge branch 'main' into feature_tracer_configurator_updates
dbarker May 13, 2026
1bafea8
Merge branch 'main' into feature_tracer_configurator_updates
dbarker May 27, 2026
ca61658
address review feedback to reduce tracer provider lock scope. use mut…
dbarker May 27, 2026
219efc6
fix iwyu and clang-tidy warnings
dbarker May 27, 2026
b22d0b2
fix iwyu warning
dbarker May 27, 2026
9b3d78b
fix iwyu warning
dbarker May 28, 2026
d8d0922
Merge branch 'main' into feature_tracer_configurator_updates
dbarker Jun 3, 2026
9646ce7
use a copy of the tracer_configurator when updateing tracer configs a…
dbarker Jun 3, 2026
a9701ea
Merge branch 'main' into feature_tracer_configurator_updates
dbarker Jun 5, 2026
57c8c3e
revert support for calling GetTracer from ComputeConfig. Initialize T…
dbarker Jun 5, 2026
3c33317
unify abiv1 and abiv2 sdk tracer enabled methods
dbarker Jun 6, 2026
f04bc5b
update tracer configurator example and documentation for clairity
dbarker Jun 6, 2026
577df29
fix example readme
dbarker Jun 6, 2026
9b550de
Merge branch 'main' into feature_tracer_configurator_updates
dbarker Jun 6, 2026
6eed017
fix markdownlint warnings
dbarker Jun 6, 2026
af92362
fix iwyu warning
dbarker Jun 6, 2026
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Increment the:

## [Unreleased]

* [SDK] Add `TracerProvider::UpdateTracerConfigurator()` and example
[#4065](https://github.com/open-telemetry/opentelemetry-cpp/issues/4065)

* [RELEASE] Bump main branch to 1.28.0-dev
[#4081](https://github.com/open-telemetry/opentelemetry-cpp/pull/4081)

Expand Down
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_subdirectory(metrics_simple)
add_subdirectory(multithreaded)
add_subdirectory(multi_processor)
add_subdirectory(environment_carrier)
add_subdirectory(tracer_configurator)
add_subdirectory(explicit_parent)

if(WITH_EXAMPLES_HTTP)
Expand Down
12 changes: 12 additions & 0 deletions examples/tracer_configurator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

add_executable(example_tracer_configurator main.cc)
target_link_libraries(
example_tracer_configurator PRIVATE opentelemetry-cpp::trace
opentelemetry-cpp::ostream_span_exporter)

if(BUILD_TESTING)
add_test(NAME examples.tracer_configurator
COMMAND "$<TARGET_FILE:example_tracer_configurator>")
endif()
162 changes: 162 additions & 0 deletions examples/tracer_configurator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Tracer Configurator Example

This example demonstrates how to set a `TracerConfigurator` on construction
of the `TracerProvider` and to update it at runtime using
`TracerProvider::UpdateTracerConfigurator` to enable or disable specific
tracers without restarting the application or recreating the tracers.

`TracerProvider::UpdateTracerConfigurator` is thread-safe and updates the
`TracerConfig` on all existing tracers.

Three tracers with unique instrumentation scope names are used to simulate
a user application:

- `my_application`: simulated user application
- `my_library`: simulated user library
- `external_library`: simulated external third-party library

The example walks through a simulated debugging workflow in four stages:

- Stage 1: Disable all tracers by default
- Stage 2: Enable `my_application` and `my_library` tracers to identify
the failed spans in user code
- Stage 3: Enable all tracers to observe the root cause failure in the
`external_library` span
- Stage 4: Disable all tracers after investigation completes

## Build and run

```sh
~/build/examples/tracer_configurator/example_tracer_configurator
```

**Expected output:**

Spans are exported to stdout via the `OStreamSpanExporter`.

```sh
=== Stage 1: all tracers initially disabled ===
[my_application] Execute
[my_library] Execute
[external_library] Execute

=== Stage 2: enable only 'my_application' and 'my_library' tracers ===
[my_application] Execute
[my_library] Execute
[external_library] Execute
{
name : MyModule.Execute
trace_id : 114712fa76ad1cf9ad4579c2b9518306
span_id : 9d153f90c7d7f340
tracestate :
parent_span_id: fdc14dfb5123734b
start : 1780785207912694667
duration : 15368223
description :
span kind : Internal
status : Error
attributes :
events :
links :
resources :
telemetry.sdk.version: 1.28.0-dev
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: cpp
service.name: tracer_configurator_example
instr-lib : my_library
}
{
name : MyApplication.Execute
trace_id : 114712fa76ad1cf9ad4579c2b9518306
span_id : fdc14dfb5123734b
tracestate :
parent_span_id: 0000000000000000
start : 1780785207912633155
duration : 15497061
description :
span kind : Internal
status : Error
attributes :
events :
links :
resources :
telemetry.sdk.version: 1.28.0-dev
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: cpp
service.name: tracer_configurator_example
instr-lib : my_application
}

=== Stage 3: enable all tracers ===
[my_application] Execute
[my_library] Execute
[external_library] Execute
{
name : ExternalModule.Execute
trace_id : 0531e8205c197402d4a0a3676cd62590
span_id : 80e266e7bbaf8779
tracestate :
parent_span_id: bdb35ecc3959a13f
start : 1780785207933329412
duration : 10081972
description : Something went wrong in external_library
span kind : Internal
status : Error
attributes :
events :
links :
resources :
telemetry.sdk.version: 1.28.0-dev
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: cpp
service.name: tracer_configurator_example
instr-lib : external_library
}
{
name : MyModule.Execute
trace_id : 0531e8205c197402d4a0a3676cd62590
span_id : bdb35ecc3959a13f
tracestate :
parent_span_id: b14ce47b2d3e9057
start : 1780785207928203132
duration : 15260338
description :
span kind : Internal
status : Error
attributes :
events :
links :
resources :
telemetry.sdk.version: 1.28.0-dev
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: cpp
service.name: tracer_configurator_example
instr-lib : my_library
}
{
name : MyApplication.Execute
trace_id : 0531e8205c197402d4a0a3676cd62590
span_id : b14ce47b2d3e9057
tracestate :
parent_span_id: 0000000000000000
start : 1780785207928189006
duration : 15305320
description :
span kind : Internal
status : Error
attributes :
events :
links :
resources :
telemetry.sdk.version: 1.28.0-dev
telemetry.sdk.name: opentelemetry
telemetry.sdk.language: cpp
service.name: tracer_configurator_example
instr-lib : my_application
}

=== Stage 4: disable all tracers ===
[my_application] Execute
[my_library] Execute
[external_library] Execute
```
Loading
Loading