Skip to content

Skip a failing resource detector instead of losing every provider - #5

Open
ocelotl wants to merge 2 commits into
dash0-v1.45.2from
contain-resource-detector-failures
Open

ocelotl wants to merge 2 commits into
dash0-v1.45.2from
contain-resource-detector-failures

Conversation

@ocelotl

@ocelotl ocelotl commented Nov 28, 2026 •

Copy link
Copy Markdown

What was broken

_run_detectors in opentelemetry-configuration/src/opentelemetry/configuration/_resource.py called load_entry_point with nothing around it, and load_entry_point raises ConfigurationError when the named entry point is not registered. configure_sdk calls create_resource before it builds the tracer, meter and logger providers and before it sets the propagator, so that exception escaped configure_sdk and left the whole SDK unconfigured.

For example, on a host without opentelemetry-resource-detector-container installed, the configuration file below is enough to trigger the failure:

resource:
  detection/development:
    detectors:
      - container: {}
ConfigurationError: Plugin 'container' not found in group 'opentelemetry_resource_detector'
tracer provider after failure: ProxyTracerProvider

container is a first-class schema field under $defs.ExperimentalResourceDetector, so a configuration file copied from the schema or from another language's example reaches the same failure. A detector whose entry point loads and whose detect() then raises escaped configure_sdk the same way, and load_entry_point never sees that one at all.

What changed

Every detector in a detector entry now runs under a handler. ConfigurationError logs a warning naming the detector, _run_detectors logs any other exception through _logger.exception, and the detectors listed after the failing one still run. configure_instrumentation already handles an absent instrumentor that way, so the two paths now agree.

_run_detectors collects the dataclass fields and additional_properties into one list before the loop. That keeps the handler in one place and preserves the order the two previous loops ran in.

Verification

pytest opentelemetry-configuration/tests passes, 453 tests and 46 subtests, against the pinned test-requirements.txt. pylint rates _resource.py 10.00/10, and ruff check and ruff format --check pass on both changed files.

Two tests that asserted the ConfigurationError reaching the caller now assert the warning and the resource that create_resource still returns. Three tests are new: a missing package, a detector raising from detect(), and container listed ahead of host with no container package installed, where host.name is still detected.

Downstream

Reported as dash0hq/opentelemetry-python-distribution#145, which vendors this package through scripts/vendor_configuration.py.

create_resource runs before configure_sdk builds the tracer, meter and
logger providers and before it sets the propagator, and _run_detectors let
a ConfigurationError out of load_entry_point. A configuration file naming
a detector whose package is not installed, such as container with no
opentelemetry-resource-detector-container on the path, therefore cost the
application traces, metrics, logs and propagation, and not only the
attributes that detector would have added.

Each requested detector now runs under a handler. A detector that cannot
be loaded logs a warning naming it, one that raises inside detect() logs
an exception, and the detectors after it still run. This is what
configure_instrumentation already does for an absent instrumentor.

The two tests that asserted the ConfigurationError reaching the caller now
assert the warning and the resource that is still returned.
One test drives a detector whose entry point loads and whose detect()
raises, which load_entry_point never sees, and asserts the resource still
carries the SDK defaults. The other lists container ahead of host with no
container package installed, and asserts host.name is still detected.
@ocelotl ocelotl changed the title Contain a failing resource detector instead of losing every provider Skip a failing resource detector instead of losing every provider Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant