Skip to content

Commit ddbdd12

Browse files
committed
rename 'known/unknown' to 'built-in/plugin' in declarative config
Update docstrings, comments, and test names to use clearer terminology for components that are built into the SDK vs loaded via entry points as plugins. Covers the already-merged sampler PR and shared infrastructure. The pending propagator, exporter, and resource detector PRs will need the same rename applied when they merge. Assisted-by: Claude Opus 4.6
1 parent 369644c commit ddbdd12

6 files changed

Lines changed: 11 additions & 10 deletions

File tree

.changelog/5195.changed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
`opentelemetry-sdk`: rename "known/unknown" to "built-in/plugin" terminology in declarative config plugin loading code

opentelemetry-sdk/codegen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Custom [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-gen
66

77
Extends the default dataclass template to support `additionalProperties` from the JSON Schema. Schema types that allow additional properties (e.g. `Sampler`, `SpanExporter`, `TextMapPropagator`) get:
88

9-
- `@_additional_properties` decorator — captures unknown constructor kwargs
9+
- `@_additional_properties` decorator — captures plugin/custom constructor kwargs
1010
- `additional_properties: ClassVar[dict[str, Any]]` annotation — satisfies type checkers without creating a dataclass field
1111

1212
This enables plugin/custom component names to flow through typed dataclasses without a post-processing step.

opentelemetry-sdk/codegen/dataclass.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Extends the default datamodel-codegen dataclass template to support
33
JSON Schema additionalProperties. When a schema type allows additional
44
properties (e.g. Sampler, SpanExporter), this template adds:
5-
- @_additional_properties decorator (captures unknown kwargs)
5+
- @_additional_properties decorator (captures plugin/custom kwargs)
66
- additional_properties: ClassVar[dict[str, Any]] annotation (for type checkers)
77
88
The template checks two context variables set by datamodel-codegen:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
def _additional_properties(cls):
1717
"""Decorator for dataclasses whose JSON Schema sets additionalProperties.
1818
19-
Wraps the dataclass-generated ``__init__`` so that unknown keyword
19+
Wraps the dataclass-generated ``__init__`` so that extra keyword
2020
arguments are captured into an ``additional_properties`` instance
21-
attribute instead of raising ``TypeError``. This lets plugin/custom
21+
attribute instead of raising ``TypeError``. This lets plugin
2222
component names flow through the config pipeline without modifying
23-
the codegen output for known fields.
23+
the codegen output for built-in fields.
2424
2525
Applied automatically by the custom template in ``opentelemetry-sdk/codegen/``
2626
when ``additionalPropertiesType`` is present in the template context

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ def _create_span_processor(
177177
def _create_sampler(config: SamplerConfig) -> Sampler:
178178
"""Create a sampler from config.
179179
180-
Known sampler types are checked via typed fields on the Sampler
181-
dataclass. Unknown sampler names captured in additional_properties
180+
Built-in sampler types are checked via typed fields on the Sampler
181+
dataclass. Plugin sampler names captured in additional_properties
182182
by the @_additional_properties decorator are loaded via the
183183
``opentelemetry_sampler`` entry point group.
184184
"""
@@ -195,7 +195,7 @@ def _create_sampler(config: SamplerConfig) -> Sampler:
195195
name = next(iter(config.additional_properties))
196196
return load_entry_point("opentelemetry_sampler", name)()
197197
raise ConfigurationError(
198-
f"Unknown or unsupported sampler type in config: {config!r}. "
198+
f"Unsupported sampler type in config: {config!r}. "
199199
"Supported types: always_on, always_off, trace_id_ratio_based, parent_based."
200200
)
201201

opentelemetry-sdk/tests/_configuration/test_tracer_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def test_parent_based_with_delegate_samplers(self):
207207
self.assertIs(sampler._local_parent_sampled, ALWAYS_ON)
208208
self.assertIs(sampler._local_parent_not_sampled, ALWAYS_OFF)
209209

210-
def test_unknown_sampler_raises_configuration_error(self):
210+
def test_no_sampler_raises_configuration_error(self):
211211
with self.assertRaises(ConfigurationError):
212212
self._make_provider(SamplerConfig())
213213

@@ -222,7 +222,7 @@ def test_plugin_sampler_loaded_via_entry_point(self):
222222
provider = self._make_provider(SamplerConfig(my_custom_sampler={}))
223223
self.assertIs(provider.sampler, mock_sampler)
224224

225-
def test_unknown_plugin_raises_configuration_error(self):
225+
def test_plugin_sampler_not_found_raises_configuration_error(self):
226226
with patch(
227227
"opentelemetry.sdk._configuration._common.entry_points",
228228
return_value=[],

0 commit comments

Comments
 (0)