Warn on conflicting metric identities between views matching the same instrument - #5630
Open
Eason09053360 wants to merge 2 commits into
Open
Conversation
…ment The metric identity conflict check in MetricReaderStorage only scanned the matches of previously registered instruments, so two views matching the same instrument with identical stream identities were both exported without the spec-mandated warning. Include the in-progress match list in the scan. Drop-aggregation matches are excluded from the check because dropped streams are never exported and cannot conflict.
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-05 14:20 UTC Review the latest changes. Status above doesn't look right?
|
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
MetricReaderStorage._handle_view_instrument_matchwarns when a new_ViewInstrumentMatchconflicts with an existing one ("Views ... will causeconflicting metrics identities"), but the check only scans
self._instrument_view_instrument_matches.values()— the matches ofpreviously registered instruments. The list being built for the current
instrument is written to that dict only after every view has been processed,
so two views matching the same instrument with identical stream identities
were never compared: both streams were exported under the same name in one
payload and nothing was logged.
The spec requires the warning
(sdk.md#view):
The same conflict split across two instruments (
View(instrument_name="c1", name="foo")+View(instrument_name="c2", name="foo")) already warned, soonly the same-instrument path was affected.
This PR includes the in-progress match list in the conflict scan. It also
excludes drop-aggregation matches from
conflicts(): dropped streams are neverexported (
collect()skips_DropAggregation), so layered drop views such asView("http.client.*", aggregation=DropAggregation())+View("*", aggregation=DropAggregation())must not trigger the warning.Out of scope, tracked in #5629: the
_DEFAULT_VIEWfallback path stillappends its match without a conflict check, so a view-renamed stream colliding
with a default-view stream is only reported in one registration order.
Type of change
How Has This Been Tested?
test_view_instrument_match_conflict_9: two views on the sameinstrument with identical identity → warning (fails without the fix with
no logs of level WARNING).test_view_instrument_match_conflict_10: two views on the sameinstrument with different names → no warning.
test_view_instrument_match_conflict_11: two overlapping drop views onthe same instrument → no warning.
test_creates_view_instrument_matchesandtest_forwards_calls_to_view_instrument_matchnow assert the warning thattheir mocked
conflicts()(a truthyMock) triggers on the firstmeasurement, matching how they already handled the cross-instrument case.
opentelemetry-sdk/tests/metrics/— 334 passed, 1 skipped.Does This PR Require a Contrib Repo Change?
Checklist: