Repository navigation
Conversation
…sing every provider Re-vendor the configuration package from dash0hq/opentelemetry-python dash0-v1.45.2 at e68f4b9, which runs each resource detector under a handler. _sdk.configure_sdk builds the resource before the tracer, meter and logger providers and before the propagator, and _resource._run_detectors let a ConfigurationError out of load_entry_point. A configuration file naming a detector whose package is not installed, such as container on a host without opentelemetry-resource-detector-container, therefore cost the application traces, metrics, logs and propagation. A detector that cannot be loaded now logs a warning naming it, one that raises inside detect() logs an exception, and the detectors after it still run. instrumentation.configure_instrumentation already did this for an absent instrumentor.
…e distro to 0.4.2 The wheels for 0.66b2.post1 and 0.4.1 are already in scripts/index-manifest.json, so the release workflow would skip rebuilding them and consumers would keep resolving the published bytes. The distro's exact pin on the configuration package moves with it.
Four tests, all of which fail against the previously vendored tree. Two call create_resource with container listed and no container package installed, once letting load_entry_point fail and once letting detect() raise, and assert the resource still carries the SDK defaults. Two run configure_sdk in a subprocess, because a process accepts global providers only once, and assert the global tracer provider is a TracerProvider rather than the ProxyTracerProvider left behind when resource creation failed.
…installed The page tells a reader to name detectors in a configuration file without saying what an absent one does. It now says the detector is skipped with a warning, and names container as the schema field whose package this distribution does not ship.
… the file The changelog entry and docs/resource-detection.md both promise that the detectors after a failing one still run, and nothing in this repository held the vendored tree to it. A re-vendor from a fork commit that moved the handler to wrap the whole loop would pass every check here. The new test lists container ahead of host and asserts host.name is detected. The annotations bring the file in line with test_propagator.py and test_vendoring.py, the two files beside it.
Without a timeout, a child process that never exits leaves subprocess.run waiting, and the test job in .github/workflows/ci.yml declares no timeout-minutes, so all six matrix entries would run to the six-hour GitHub default and report a cancellation rather than a failure.
caplog.at_level sets a minimum, so the ERROR a collapsed handler emits also landed in caplog.text and the warning test stayed green. Collapsing the two except clauses into one _logger.exception would print a stack trace on every start for the container case this change exists for. Asserting the level and whether the record carries exc_info fails that edit: experimentally, with the clauses collapsed, the warning test reports assert ['ERROR'] == ['WARNING'].
…lked through Hoisting the generic handler outside the loop, dropping the exception from the warning message, and dropping the detector name from it all left the suite green. A sixth test lists host after a container detector whose detect() raises, and the warning test now asserts the rendered message starts with the detector name and still carries the sentence telling an operator to install the package. The subprocess helper asserts on returncode with stderr as the message instead of passing check=True. CalledProcessError reports the exit status and echoes the program source, so a CI log for a future regression carried nothing about why the child failed.
Neither test read caplog.records, so the fixture and the at_level block changed no outcome while telling a reader the test checks the log. The ERROR one also raised the logger above WARNING for the duration of the call, which would have hidden a downgrade of the generic handler. The two tests above them already pin the level and the message for both routes.
The four in-process tests all list `container`, a declared field of `ExperimentalResourceDetector`, so nothing pinned the other route into `_run_detectors`: a name the schema omits, which arrives through `additional_properties`. Restoring the separate unguarded loop for that route left the whole suite passing, and the three detectors the documented example lists travel it.
Every test that makes a detector fail makes `container` fail, which takes the entry-point branch. The `_RESOURCE_DETECTOR_REGISTRY` branch was only ever reached by `host`, which always succeeds, so guarding the entry-point branch alone left the suite green. `ProcessResourceDetector.detect` calls `psutil.Process().username()` unguarded, so `AccessDenied` from a sandboxed runtime reaches that branch.
`ruff.toml` sets `line-length = 88` and excludes only the configuration package's `src`, so the tests are in scope. Both docstrings were 90 columns. CI never passes this directory to ruff, so nothing reported it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #145
What was broken
_sdk.configure_sdkbuilds the resource before it installs the tracer, meter and logger providers and before it sets the propagator._resource._run_detectorscalledload_entry_pointwith nothing around it, andload_entry_pointraisesConfigurationErrorwhen the named entry point is not registered. A configuration file naming a detector whose package is not installed therefore cost the application traces, metrics, logs and propagation, and not only the attributes that detector would have added.containeris a first-class schema field under$defs.ExperimentalResourceDetector, and this distribution does not shipopentelemetry-resource-detector-container. The installed entry points aredash0_distribution,dash0_kubernetes,dash0_service_name,host,os,otel,processandservice_instance. For example, a file copied from the schema, or from another language's example, reaches the failure:A detector whose entry point loads and whose
detect()then raises escaped the same way, andload_entry_pointnever sees that one at all.What changed
scripts/vendor_configuration.pygeneratespackages/dash0-opentelemetry-configuration/from thedash0-v1.45.2branch of https://github.com/dash0hq/opentelemetry-python, so the code change was made there and vendored in. The fork pull request is dash0hq/opentelemetry-python#5, andUPSTREAMnow names its head commite68f4b9._run_detectorsruns every detector in a detector entry under a handler.ConfigurationErrorlogs a warning naming the detector,_run_detectorslogs any other exception through_logger.exception, and the detectors listed after the failing one still run.instrumentation.configure_instrumentationalready handles an absent instrumentor that way, so the two paths now agree.The configuration package moves to 0.66b2.post2 and the distribution to 0.4.2, because the wheels for 0.66b2.post1 and 0.4.1 are already in
scripts/index-manifest.json.Verification
packages/dash0-opentelemetry-configuration/tests/test_resource_detector_failures.pyholds eight tests, and all eight fail against the previously vendored tree.Four call
create_resourcewithcontainerlisted, two per failure route. On the route whereload_entry_pointcannot find the entry point, one asserts a single WARNING record whose rendered message starts with the detector name and still carries the sentence telling an operator to install the package, and the other listshostaftercontainerand assertshost.nameis still detected. On the route wheredetect()raises, one asserts a single ERROR record carrying a traceback, and the other again assertshost.name.Two cover the branches
containernever reaches._run_detectorsresolveshost,processandservicethrough_RESOURCE_DETECTOR_REGISTRYand everything else through the entry point group, and it reads the four schema fields andadditional_propertiesinto one list.containeris a schema field resolved by entry point, so one test listsaws_ecs, which the schema does not declare and which therefore arrives throughadditional_properties, and the other makes the registry entry forprocessraise.Two run
configure_sdkin a subprocess, because a process accepts global providers only once, and assert the global tracer provider is aTracerProviderrather than theProxyTracerProviderleft behind when resource creation failed.Five mutations of
_run_detectorssurvived an earlier shape of these tests and are now killed: hoisting the generic handler outside the loop, dropping the exception from the warning message, dropping the detector name from it, restoring the separate unguarded loop overadditional_properties, and running the registry detectors ahead of thetry.Every check below ran on
issue_145_contain_detector_failure.uvx ruff@latest check packages/dash0-opentelemetry examples scriptsuvx ruff@latest format --check packages/dash0-opentelemetry examples scriptsuv lock --checkuv run --no-project --python 3.13 scripts/check_pinned_dependencies.pyuv run --no-project --python 3.13 scripts/check_version_bumped.pyuv run --no-project --python 3.13 python scripts/vendor_configuration.py --checke68f4b9uv run --no-project --with packaging --python 3.13 python scripts/refresh_injector_manifest.py --checkpytest packages/dash0-opentelemetry-configuration/tests packages/dash0-opentelemetry/testspytest scripts/testsmake chlog-validateThe fork's own suite passes too, 453 tests and 46 subtests under
pytest opentelemetry-configuration/tests, withpylintrating_resource.py10.00/10.Why this is a draft, and what has to happen before it merges
UPSTREAMnamese68f4b9, the head commit of the open fork pull request.git branch -a --contains e68f4b9on the fork lists onlycontain-resource-detector-failures, soUPSTREAMcurrently records a commit that the branch it also records,dash0-v1.45.2, does not contain.scripts/vendor_configuration.pyfetches by bare SHA and never reads thebranchfield, so--checkpasses anyway and nothing in CI reports the mismatch. A maintainer who later runs the script with no--commitwould regenerate from the fork pull request's head ref instead of fromdash0-v1.45.2.So, in order:
dash0-v1.45.2.uv run --no-project --python 3.13 python scripts/vendor_configuration.py --commit <sha on dash0-v1.45.2>here and commit the result.git branch -a --contains <that sha>on the fork thatorigin/dash0-v1.45.2is listed.#126 pinned
90f23adthe same way, and the fork pull request carrying90f23adhad already merged when it did.