feat(config): unify declarative and env-var configuration through a shared SDK orchestrator
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
opentelemetry/sdk/_configuration/init.py の _initialize_components() と、シグナル固有のファクトリである _tracer_provider.py、_logger_provider.py、_meter_provider.py、_propagator.py、_resource.py から始めます。段階的なスコープを定義する前に、既存の _OTelSDKConfigurator と _BaseConfigurator の拡張ポイントを追跡します。宣言的なパスに共有の configure_sdk() エントリーポイントがあり、既存のコンストラクターの動作と distro 互換性が維持されていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Motivation
Today there are two independent configuration paths that construct the SDK:
-
Env-var path —
_initialize_components()inopentelemetry/sdk/_configuration/__init__.pyorchestrates SDK init, but env-var reading is scattered across individual SDK classes (TracerProvider,BatchSpanProcessor,Resource,MeterProvider, sampling, etc.). Each class reads its ownOTEL_*vars at construction time. -
Declarative file path — modular
create_*/configure_*factory functions per signal (_tracer_provider.py,_logger_provider.py,_meter_provider.py,_propagator.py,_resource.py), but no top-level orchestrator that ties them together.
This split means:
- Env-var reading logic is duplicated or scattered, making it hard to maintain
- There's no single "apply this config" entry point for the declarative path
- The two paths can drift in behavior since they don't share construction logic
Proposal
1. Add a top-level configure_sdk(config) orchestrator
A single function that takes an OpenTelemetryConfiguration and calls all configure_* functions in the correct order:
def configure_sdk(config: OpenTelemetryConfiguration) -> None:
resource = create_resource(config.resource)
configure_tracer_provider(config.tracer_provider, resource)
configure_meter_provider(config.meter_provider, resource)
configure_logger_provider(config.logger_provider, resource)
configure_propagator(config.propagator)
2. Add an env-var-to-config adapter
A function that reads all OTEL_* env vars and produces an OpenTelemetryConfiguration, which then flows through the same configure_sdk() path:
def load_config_from_env() -> OpenTelemetryConfiguration:
"""Read OTEL_* env vars and build an OpenTelemetryConfiguration."""
...
End state
YAML file → load_config_file() → OpenTelemetryConfiguration → configure_sdk()
env vars → load_config_env() → OpenTelemetryConfiguration → configure_sdk()
Both paths converge on the same construction logic, eliminating drift.
Considerations
- Scattered env-var reads in constructors:
BatchSpanProcessor.__init__,TracerProvider.__init__, etc. read env vars when no explicit value is passed. Changing this touches public API surface and needs careful deprecation. - Spec requirement: Individual components must respect env vars when no explicit config value is provided. A pure "read everything upfront" approach needs to distinguish "not configured" from "explicitly set to default".
- Backwards compatibility: The existing
_OTelSDKConfigurator/_BaseConfiguratorpattern is used by distros. Any refactor needs to preserve that extension point. - Scope: This is a large refactor best done incrementally — start with
configure_sdk()for the declarative path, then gradually migrate env-var reading.
Related
- #3631 — declarative config tracking issue
- 主要言語
- Python
- スター
- 2.7k
- フォーク
- 1.1k
- 平均マージ
- 3日 12時間
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
open-telemetry/opentelemetry-python のほかの issue
-
References to Archived open-telemetry/oteps対応中かも @RjyavardhanSingh が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-telemetry/opentelemetry-python#5984 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/json対応中かも @WendeelMarinho が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
open-telemetry/opentelemetry-python#5981 ·
メンテナーはふだん 2 日以内に返信
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTER対応中かも @bishalde が 8 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
open-telemetry/opentelemetry-python#5948 · コメント 3 件 ·
メンテナーはふだん 2 日以内に返信
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagate対応中かも @codedbyadiiii が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
open-telemetry/opentelemetry-python#5913 ·
メンテナーはふだん 2 日以内に返信
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
open-telemetry/opentelemetry-python#5891 ·
メンテナーはふだん 2 日以内に返信
open-telemetry/opentelemetry-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug improve content
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
opensafely/documentation#2102 ·
メンテナーはふだん 1 日以内に返信
-
difficulty:1 documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MakazhanAlpamys/Soup#3533 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
onyx-dot-app/onyx#18730 ·
メンテナーはふだん 1 日以内に返信