feat(config): unify declarative and env-var configuration through a shared SDK orchestrator
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với _initialize_components() trong opentelemetry/sdk/_configuration/init.py và các factory dành riêng cho từng signal: _tracer_provider.py, _logger_provider.py, _meter_provider.py, _propagator.py và _resource.py. Theo dõi các điểm mở rộng hiện có của _OTelSDKConfigurator và _BaseConfigurator trước khi xác định phạm vi gia tăng. Công việc được xem là hoàn tất khi đường dẫn khai báo có một điểm vào configure_sdk() dùng chung, đồng thời giữ nguyên hành vi của constructor hiện có và khả năng tương thích với distro.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 2.7k
- Fork
- 1.1k
- Merge trung bình
- 3 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 16
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của open-telemetry/opentelemetry-python
-
References to Archived open-telemetry/otepsCó thể đã có người làm @RjyavardhanSingh đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
open-telemetry/opentelemetry-python#5984 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/jsonCó thể đã có người làm @WendeelMarinho đã nhận 2 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
open-telemetry/opentelemetry-python#5981 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTERCó thể đã có người làm @bishalde đã nhận 8 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
open-telemetry/opentelemetry-python#5948 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagateCó thể đã có người làm @codedbyadiiii đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
open-telemetry/opentelemetry-python#5913 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
open-telemetry/opentelemetry-python#5891 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của open-telemetry/opentelemetry-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug improve content
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
opensafely/documentation#2102 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:1 documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
MakazhanAlpamys/Soup#3533 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
onyx-dot-app/onyx#18730 ·
Maintainer thường phản hồi trong vòng 1 ngày