feat(config): unify declarative and env-var configuration through a shared SDK orchestrator
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 opentelemetry/sdk/_configuration/init.py 中的 _initialize_components() 以及特定 signal 的工厂 _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 小时
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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__可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 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 天内回复