Skip to content

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

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

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

Conversation

@MikeGoldsmith
Copy link
Copy Markdown
Member

@MikeGoldsmith MikeGoldsmith commented Apr 14, 2026

Description

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

Solution

_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)

The generated models are unchanged. Python dataclasses don't enforce field types at runtime, so the composite list naturally accepts raw dicts (from the YAML loader) alongside typed TextMapPropagator instances. This preserves unknown plugin names as dict keys without diverging from codegen.

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
Python dataclasses don't enforce types at runtime, so factory
functions can accept raw dicts directly. This removes the need to
change TextMapPropagator from a @DataClass to a TypeAlias.

Assisted-by: Claude Opus 4.6 (1M context)
@MikeGoldsmith MikeGoldsmith marked this pull request as draft April 20, 2026 13:52
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