fix(sdk): check default-view fallback stream for conflicting metric identities - #5632
Open
somuai wants to merge 2 commits into
Open
fix(sdk): check default-view fallback stream for conflicting metric identities#5632somuai wants to merge 2 commits into
somuai wants to merge 2 commits into
Conversation
somuai
pushed a commit
to somuai/opentelemetry-python
that referenced
this pull request
Sep 5, 2026
Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
…ties Fixes open-telemetry#5629 MetricReaderStorage creates metric streams for instruments either via matching user-configured views in _handle_view_instrument_match or via the _DEFAULT_VIEW fallback in _get_or_init_view_instrument_match when no views match. Previously, only _handle_view_instrument_match executed conflict checking against existing matches. As a result, when an explicit view renamed an instrument to a name matching an instrument that uses the default-view fallback, the conflict warning was only emitted if the renamed instrument arrived second. If the renamed instrument arrived first, the default-view fallback stream was appended without checking for conflicts, silently exporting duplicate metric identities in violation of the OpenTelemetry specification. Extract _check_conflicts_and_add_match to route both stream-creation paths through conflict scanning, ensuring conflicting metric identities are reliably warned regardless of instrument registration order. Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
somuai
force-pushed
the
fix-default-view-conflict-warning
branch
from
September 5, 2026 21:17
3e24b18 to
0b609ab
Compare
Author
|
/dashboard route:reviewers |
|
@somuai, this pull request was routed to reviewers. |
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-05 23: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 #5629
MetricReaderStoragecreates metric streams for instruments either via matching user-configured views in_handle_view_instrument_matchor via the_DEFAULT_VIEWfallback in_get_or_init_view_instrument_matchwhen no view matches the instrument.Previously, only
_handle_view_instrument_matchexecuted conflict scanning against existing matches. As a result, when an explicit view renamed an instrument to collide with an instrument taking the fallback path, the duplicate identity warning ("Views ... will cause conflicting metrics identities") was emitted only if the renamed instrument recorded second. If the renamed instrument recorded first, the fallback stream was appended without a conflict check, and two streams with identical identity were exported without warning.Per the OpenTelemetry specification (https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view):
This change extracts
_check_conflicts_and_add_matchto ensure both stream-creation paths (matching views and the_DEFAULT_VIEWfallback) perform conflict scanning against existing matches before appending, guaranteeing consistent, order-independent warning behavior.Type of change
How Has This Been Tested?
test_view_instrument_match_conflict_default_view_order_independencetesting both arrival orders (default view first vs renamed view first). Both orders reliably emit the warning.test_default_view_enabledto assert the conflict warning emitted when a second instrument with a mocked match is recorded.opentelemetry-sdk/tests/metrics/test_metric_reader_storage.py(18/18 passed).ruff check(clean).Does This PR Require a Contrib Repo Change?
Checklist: