Repository navigation
fix(sdk): warn on conflicting metric identities for views matching the same instrument - #5932
Open
anjalimishra-0007 wants to merge 1 commit into
Conversation
…e same instrument Fixes open-telemetry#5627 Assisted-by: Google Antigravity Signed-off-by: Anjali Mishra <246823347+anjalimishra-0007@users.noreply.github.com>
Pull request dashboard statusWaiting on reviewers · refreshed 2026-11-13 12:38 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
Fixes #5627
When multiple views match the same instrument and produce identical metric stream identities (e.g. same output name, unit, and description),
MetricReaderStorage._handle_view_instrument_matchiteratesself._instrument_view_instrument_matches.values()to detect conflicts. However, new_ViewInstrumentMatchinstances created for the active instrument are only accumulated inview_instrument_matchesand not inserted intoself._instrument_view_instrument_matchesuntil after the view loop completes. As a result, conflicting views targeting the same instrument never emitted the specification-mandated conflict warning.In addition:
_ViewInstrumentMatch.conflicts()is updated so that views configured with_DropAggregationnever trigger conflict warnings (whether both views drop or one drops and the other does not), because dropped metric streams are never exported and cannot produce duplicate time series.MetricReaderStorage._handle_view_instrument_match,view_instrument_matchesis included in the outer conflict check loop alongside*self._instrument_view_instrument_matches.values(), enabling detection of conflicts among views matching the same instrument.This incorporates maintainer feedback from earlier discussions on #5630.
Type of change
Checklist:
tox -e precommittox -e typecheckTesting performed locally:
pytest opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py: 21 passed (including 3 new tests:test_view_instrument_match_conflict_9,10, and11)pytest opentelemetry-sdk/tests/metrics/: 373 passed, 1 skipped (Windows-only skip), 0 failuresruff check: all checks passedruff format --check: all files formatted.changelog/5627.fixed