opentelemetry-sdk: Implement tracer configurator by xrmx · Pull Request #4861 · open-telemetry/opentelemetry-python

aabmass

xrmx

xrmx

jack-berg

herin049

mariojonke

Implement part of the tracing SDK spec to configure the tracers
https://opentelemetry.io/docs/specs/otel/trace/sdk/#configuration

At the moment this adds helper in order to enable or disable a tracer
after it has been created.

The spec in is development so attributes, helpers and classes are
prefixed with underscore.

TODO: hook into sdk configuration

@xrmx

@xrmx

@xrmx

@xrmx

@xrmx

@xrmx

@xrmx

@xrmx

@xrmx

…eclarative config schema

@xrmx

@xrmx

@xrmx

@xrmx

herin049

aabmass

@xrmx

@xrmx

So instead of caching it when the TracerConfigurator changes calculate
it when we need to check if the tracer is enabled. This simplify the
code quite a bit and hopefully people will use fast tracer configurator.

pmcollins

pmcollins

@xrmx

@xrmx

JWinermaSplunk pushed a commit to JWinermaSplunk/opentelemetry-python that referenced this pull request

Feb 17, 2026
* opentelemetry-sdk: Implement tracer configurator

Implement part of the tracing SDK spec to configure the tracers
https://opentelemetry.io/docs/specs/otel/trace/sdk/#configuration

At the moment this adds helper in order to enable or disable a tracer
after it has been created.

The spec in is development so attributes, helpers and classes are
prefixed with underscore.

TODO: hook into sdk configuration

* Please lint

* Add rule based tracer configurator

* Assume rule based tracer configurator in helpers

* Fix lint

* Add changelog

* hook into auto-instrumentation

* Don't return invalid spans from NoOpTracer

* Adapt after nooptracer behaviour change

* Please lint

* Rework _RuleBasedTracerConfigurator interface to match the one from declarative config schema

* More correct nooptracer and more test coverage

* Ignore typechecking in validation test

* Handle invalid span context more gracefully

* Return invalid span in case span context is invalid

* Use tuple for typing

* Add retries in case of failure in copying the cached tracers

* Calculate the TracerConfig in start_span

So instead of caching it when the TracerConfigurator changes calculate
it when we need to check if the tracer is enabled. This simplify the
code quite a bit and hopefully people will use fast tracer configurator.

* Make Tracer.is_enabled a method since it does some computation

* Add benchmarks

* Test also the case with no overhead

* Use functools.lru_cache to recover the overhead of tracerConfigurator

* Fix pylint

* Fix precommit

* Make scope matcher generic per Lukas suggestion