Skip to content

Commit 4809d80

Browse files
committed
revert models.py changes, use raw dicts without modifying codegen
Python dataclasses don't enforce types at runtime, so factory functions can accept raw dicts without changing the generated models. This keeps models.py identical to the codegen output. Assisted-by: Claude Opus 4.6 (1M context)
1 parent 93ec1fe commit 4809d80

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

  • opentelemetry-sdk/src/opentelemetry/sdk/_configuration

opentelemetry-sdk/src/opentelemetry/sdk/_configuration/models.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,24 @@ class ExperimentalJaegerRemoteSampler:
759759
interval: int | None = None
760760

761761

762-
# Diverges from codegen: Sampler and ParentBasedSampler are typed as
763-
# dict[str, Any] rather than dataclasses so that unknown sampler names
764-
# (plugin/custom samplers) are preserved as dict keys through the config
765-
# pipeline. The loader stores nested fields as raw dicts anyway, so the
766-
# typed dataclass representation would drop unknown keys silently.
767-
Sampler: TypeAlias = dict[str, Any]
768-
ParentBasedSampler: TypeAlias = dict[str, Any]
762+
@dataclass
763+
class ParentBasedSampler:
764+
root: Sampler | None = None
765+
remote_parent_sampled: Sampler | None = None
766+
remote_parent_not_sampled: Sampler | None = None
767+
local_parent_sampled: Sampler | None = None
768+
local_parent_not_sampled: Sampler | None = None
769+
770+
771+
@dataclass
772+
class Sampler:
773+
always_off: AlwaysOffSampler | None = None
774+
always_on: AlwaysOnSampler | None = None
775+
composite_development: ExperimentalComposableSampler | None = None
776+
jaeger_remote_development: ExperimentalJaegerRemoteSampler | None = None
777+
parent_based: ParentBasedSampler | None = None
778+
probability_development: ExperimentalProbabilitySampler | None = None
779+
trace_id_ratio_based: TraceIdRatioBasedSampler | None = None
769780

770781

771782
@dataclass

0 commit comments

Comments
 (0)