feat(config): unify declarative and env-var configuration through a shared SDK orchestrator
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia da _initialize_components() in opentelemetry/sdk/_configuration/init.py e dalle factory specifiche per segnale _tracer_provider.py, _logger_provider.py, _meter_provider.py, _propagator.py e _resource.py. Traccia i punti di estensione esistenti di _OTelSDKConfigurator e _BaseConfigurator prima di definire l’ambito incrementale. Il lavoro è completato quando il percorso dichiarativo dispone di un punto di ingresso configure_sdk() condiviso, preservando il comportamento esistente dei costruttori e la compatibilità con le distro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 2.7k
- Fork
- 1.1k
- Merge medio
- 3g 12h
- PR unite (30g)
- 16
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di open-telemetry/opentelemetry-python
-
References to Archived open-telemetry/otepsForse già presa @RjyavardhanSingh l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
open-telemetry/opentelemetry-python#5984 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/jsonForse già presa @WendeelMarinho l’ha presa 2 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
open-telemetry/opentelemetry-python#5981 ·
I maintainer di solito rispondono entro 2 giorni
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTERForse già presa @bishalde l’ha presa 8 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
open-telemetry/opentelemetry-python#5948 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagateForse già presa @codedbyadiiii l’ha presa 20 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
open-telemetry/opentelemetry-python#5913 ·
I maintainer di solito rispondono entro 2 giorni
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
open-telemetry/opentelemetry-python#5891 ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di open-telemetry/opentelemetry-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug improve content
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
opensafely/documentation#2102 ·
I maintainer di solito rispondono entro 1 giorno
-
difficulty:1 documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
MakazhanAlpamys/Soup#3533 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
onyx-dot-app/onyx#18730 ·
I maintainer di solito rispondono entro 1 giorno