Repository navigation
Record error.type for failed metric reader collections - #5778
Open
RichardoMrMu wants to merge 2 commits into
Open
RichardoMrMu wants to merge 2 commits into
RichardoMrMu wants to merge 2 commits into
Conversation
`otel.sdk.metric_reader.collection.duration` is documented to leave `error.type` unset for successful collections and to set it to the failure cause for failed ones. `MetricReader.collect` only recorded the duration, so a failed collection looked the same as a successful one. Pass the failure cause from `collect` to `record_collection` and set `error.type` from the exception type name. Assisted-by: Doubao
Assisted-by: Doubao
Pull request dashboard statusWaiting on reviewers · refreshed 2026-10-13 10:17 UTC Review the latest changes. Status above doesn't look right?
|
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.
Description
otel.sdk.metric_reader.collection.durationis documented with the note thaterror.typeMUST NOT be set for successful collections and SHOULD contain thefailure cause for failed ones.
MetricReader.collectonly recorded theduration, so a failed collection was indistinguishable from a successful one on
that metric.
This passes the failure cause from
collectdown torecord_collection, whichsets
error.typeto the exception type name when the collection raised. Theexception is still re-raised, and successful collections still record without
error.type.Type of change
How Has This Been Tested?
Added
TestPeriodicExportingMetricReader.test_metric_reader_metrics_failed_collection_records_error_type.It fails on main with
AssertionError: 'MetricsTimeoutError' not found in [None]and passes after the change.
pytest opentelemetry-sdk/tests(after the change): 893 passed, 20 skippedruff check,ruff format --check,pylinton the touched filesDoes This PR Require a Contrib Repo Change?
Checklist:
I used AI assistance (Doubao) to prepare this change. I reviewed the diff, ran
the tests listed above myself, and I am responsible for this submission.