Commit e19d346
authored
feat(config): generic resource detector plugin loading for declarative config (#5129)
* add generic resource detector plugin loading to declarative config
ExperimentalResourceDetector is changed from @DataClass to
TypeAlias = dict[str, Any] in models.py, preserving unknown detector
names as dict keys through the config pipeline.
_run_detectors() now iterates the dict's key-value pairs directly via
_RESOURCE_DETECTOR_REGISTRY. Known names (service, host, process) are
bootstrapped directly from the SDK. Unknown names — including container
and custom plugin detectors — are loaded via the
opentelemetry_resource_detector entry point group, matching the spec's
PluginComponentProvider mechanism.
The container detector behavior changes from warning-when-missing to
raising ConfigurationError, consistent with the fail-fast approach
agreed on in the issue discussion.
Assisted-by: Claude Opus 4.6
* update CHANGELOG with PR number #5129
* add generic resource detector plugin loading to declarative config
_run_detectors() now iterates detector config dicts directly via
_RESOURCE_DETECTOR_REGISTRY. Known names (service, host, process) are
bootstrapped directly from the SDK. Unknown names — including container
and custom plugin detectors — are loaded via the
opentelemetry_resource_detector entry point group, matching the spec's
PluginComponentProvider mechanism.
The generated models are unchanged. Python dataclasses don't enforce
field types at runtime, so the detectors list naturally accepts raw
dicts (from the YAML loader) alongside typed ExperimentalResourceDetector
instances. This preserves unknown plugin names as dict keys without
diverging from codegen.
The container detector behavior changes from warning-when-missing to
raising ConfigurationError, consistent with the fail-fast approach
agreed on in the issue discussion.
Assisted-by: Claude Opus 4.6
* update resource detector plugin loading to use additional_properties
Use typed ExperimentalResourceDetector with additional_properties from
the @_additional_properties decorator instead of raw dict iteration.
Known schema fields (service, host, process) are checked via
_RESOURCE_DETECTOR_REGISTRY. Known fields not in the registry (e.g.
container) and unknown plugin names from additional_properties are
loaded via entry points.
Assisted-by: Claude Opus 4.6
* address review feedback on resource detector PR
- use walrus operator for OTEL_SERVICE_NAME check
- use AttributeValue type hint from opentelemetry.util.types
- type _RESOURCE_DETECTOR_REGISTRY with Callable signature
- _config param typed as Any for forward compatibility
The overlap with OTELResourceDetector is minimal (3 lines for
OTEL_SERVICE_NAME reading) — not worth extracting a shared utility.
Assisted-by: Claude Opus 4.6
* merge upstream/main, fix unused import
* pass plugin config args to entry point resource detectors
Plugin detectors now receive their config as kwargs:
cls(**(plugin_config or {})).detect().attributes
Previously config values were discarded.
Assisted-by: Claude Opus 4.61 parent 1d69bd2 commit e19d346
3 files changed
Lines changed: 92 additions & 57 deletions
File tree
- .changelog
- opentelemetry-sdk
- src/opentelemetry/sdk/_configuration
- tests/_configuration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 46 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
138 | 160 | | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
142 | | - | |
| 164 | + | |
143 | 165 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
147 | 174 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
181 | 182 | | |
182 | 183 | | |
183 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
184 | 188 | | |
185 | | - | |
186 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
187 | 192 | | |
188 | 193 | | |
189 | 194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
470 | | - | |
471 | | - | |
| 471 | + | |
| 472 | + | |
472 | 473 | | |
473 | | - | |
| 474 | + | |
474 | 475 | | |
475 | 476 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
| 477 | + | |
| 478 | + | |
487 | 479 | | |
488 | 480 | | |
489 | 481 | | |
| |||
494 | 486 | | |
495 | 487 | | |
496 | 488 | | |
497 | | - | |
| 489 | + | |
498 | 490 | | |
499 | 491 | | |
500 | 492 | | |
| |||
518 | 510 | | |
519 | 511 | | |
520 | 512 | | |
521 | | - | |
| 513 | + | |
522 | 514 | | |
523 | 515 | | |
524 | 516 | | |
| |||
591 | 583 | | |
592 | 584 | | |
593 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
0 commit comments