Skip to content

feat(config): propagator plugin loading via entry points for declarative config#5098

Open
MikeGoldsmith wants to merge 3 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/config-propagator-plugin-loading
Open

feat(config): propagator plugin loading via entry points for declarative config#5098
MikeGoldsmith wants to merge 3 commits intoopen-telemetry:mainfrom
MikeGoldsmith:mike/config-propagator-plugin-loading

Conversation

@MikeGoldsmith
Copy link
Copy Markdown
Member

Depends on #5093 (shared load_entry_point utility). Best reviewed after that merges.

Description

Extends propagator support in declarative file configuration to handle custom (plugin) propagators in the composite list, matching the spec's PluginComponentProvider mechanism.

Solution

TextMapPropagator is changed from @dataclass to TypeAlias = dict[str, Any] in models.py, preserving unknown propagator names as dict keys — the same approach used for Sampler in #5095.

_propagators_from_textmap_config() now iterates the dict's key-value pairs directly via _PROPAGATOR_REGISTRY:

  • Known names (tracecontext, baggage) are bootstrapped directly from the SDK
  • All other names — including b3, b3multi, and custom plugin propagators — fall back to load_entry_point("opentelemetry_propagator", name)

Custom propagator example

propagator:
  composite:
    - tracecontext: {}
    - my_custom_propagator: {}
[project.entry-points."opentelemetry_propagator"]
my_custom_propagator = "my_package:MyPropagatorClass"

Closes #5070

Extracts a generic `load_entry_point(group, name)` helper into `_common`
so that resource detector, exporter, propagator, and sampler plugin loading
in declarative file config can all use the same entry point lookup pattern
rather than duplicating it.

Refactors `_propagator.py` to use the new util, removing its inline
entry point lookup.

Assisted-by: Claude Sonnet 4.6
TextMapPropagator is changed from @DataClass to TypeAlias = dict[str, Any]
in models.py, preserving unknown propagator names (plugin names) as dict
keys through the config pipeline — same approach as Sampler.

_propagators_from_textmap_config() now iterates the dict's key-value pairs
directly. Known names (tracecontext, baggage) are bootstrapped from
_PROPAGATOR_REGISTRY. All other names — including b3, b3multi, and custom
plugin propagators — fall back to load_entry_point("opentelemetry_propagator",
name), matching the spec's PluginComponentProvider mechanism.

Assisted-by: Claude Sonnet 4.6
@MikeGoldsmith MikeGoldsmith requested a review from a team as a code owner April 14, 2026 16:22
@MikeGoldsmith MikeGoldsmith moved this to Ready for review in Python PR digest Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

feat(config): generic plugin loading for propagators in declarative config

1 participant