Skip to content

Commit f20c680

Browse files
refactor(config): rename 'known/unknown' to 'built-in/user-defined' terminology (#5214)
* 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 * rename changelog fragment to PR #5214 * use 'user-defined' instead of 'plugin' per review feedback Rename 'plugin' to 'user-defined' throughout — pairs better with 'built-in' and is less ambiguous. Assisted-by: Claude Opus 4.6
1 parent 64d0a49 commit f20c680

6 files changed

Lines changed: 12 additions & 11 deletions

File tree

.changelog/5214.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/user-defined" terminology in declarative config component 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 user-defined 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 user-defined 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 user-defined
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
@@ -188,8 +188,8 @@ def _create_span_processor(
188188
def _create_sampler(config: SamplerConfig) -> Sampler:
189189
"""Create a sampler from config.
190190
191-
Known sampler types are checked via typed fields on the Sampler
192-
dataclass. Unknown sampler names captured in additional_properties
191+
Built-in sampler types are checked via typed fields on the Sampler
192+
dataclass. User-defined sampler names captured in additional_properties
193193
by the @_additional_properties decorator are loaded via the
194194
``opentelemetry_sampler`` entry point group.
195195
"""
@@ -206,7 +206,7 @@ def _create_sampler(config: SamplerConfig) -> Sampler:
206206
name = next(iter(config.additional_properties))
207207
return load_entry_point("opentelemetry_sampler", name)()
208208
raise ConfigurationError(
209-
f"Unknown or unsupported sampler type in config: {config!r}. "
209+
f"Unsupported sampler type in config: {config!r}. "
210210
"Supported types: always_on, always_off, trace_id_ratio_based, parent_based."
211211
)
212212

opentelemetry-sdk/tests/_configuration/test_tracer_provider.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ 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

214-
def test_plugin_sampler_loaded_via_entry_point(self):
214+
def test_user_defined_sampler_loaded_via_entry_point(self):
215215
mock_sampler = MagicMock(spec=Sampler)
216216
mock_class = MagicMock(return_value=mock_sampler)
217217
with patch(
@@ -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_user_defined_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)