Skip to content

feat(config): wire id_generator from declarative configuration to TracerProvider#5363

Open
aman-panjwani wants to merge 3 commits into
open-telemetry:mainfrom
aman-panjwani:feat/config-wire-id-generator
Open

feat(config): wire id_generator from declarative configuration to TracerProvider#5363
aman-panjwani wants to merge 3 commits into
open-telemetry:mainfrom
aman-panjwani:feat/config-wire-id-generator

Conversation

@aman-panjwani

Copy link
Copy Markdown
Contributor

Description

Wires the id_generator field from declarative configuration to TracerProvider, closing the parity gap with Java/JS SDKs. Depends on #5333 (merged) which added IdGenerator to models.py.

Fixes #5334

Changes

  • Added _ID_GENERATOR_REGISTRY and _create_id_generator in _tracer_provider.py using the existing _resolve_component helper
  • Built-in random resolves to RandomIdGenerator
  • Unknown names load from the opentelemetry_id_generator entry point group (same group OTEL_PYTHON_ID_GENERATOR uses today)
  • Threaded id_generator through create_tracer_provider - absent config passes None so the SDK applies its own RandomIdGenerator default

Tests Added

  • test_absent_id_generator_uses_sdk_default - omitted config → SDK default RandomIdGenerator
  • test_builtin_random_id_generator - built-in randomRandomIdGenerator
  • test_plugin_id_generator_loaded_via_entry_point - unknown name → loaded from opentelemetry_id_generator entry point group
  • test_unknown_id_generator_raises_configuration_error - unknown name with no matching entry point → ConfigurationError
  • test_empty_id_generator_raises_configuration_error - empty config → ConfigurationError

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Ran tox -e ruff - linter and formatter passing

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@aman-panjwani aman-panjwani requested a review from a team as a code owner June 26, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat(config): wire id_generator from declarative configuration to TracerProvider

1 participant