Skip to content

fix(sdk): warn on conflicting metric identities for views matching the same instrument - #5932

Open
anjalimishra-0007 wants to merge 1 commit into
open-telemetry:mainfrom
anjalimishra-0007:fix/view-instrument-match-same-instrument-conflict
Open

anjalimishra-0007 wants to merge 1 commit into
open-telemetry:mainfrom
anjalimishra-0007:fix/view-instrument-match-same-instrument-conflict

Conversation

@anjalimishra-0007

Copy link
Copy Markdown

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_match iterates self._instrument_view_instrument_matches.values() to detect conflicts. However, new _ViewInstrumentMatch instances created for the active instrument are only accumulated in view_instrument_matches and not inserted into self._instrument_view_instrument_matches until after the view loop completes. As a result, conflicting views targeting the same instrument never emitted the specification-mandated conflict warning.

In addition:

  1. _ViewInstrumentMatch.conflicts() is updated so that views configured with _DropAggregation never 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.
  2. In MetricReaderStorage._handle_view_instrument_match, view_instrument_matches is 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

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I am a human and not a bot
  • I have run tox -e precommit
  • I have run tox -e typecheck
  • I have run the relevant tests and linting tox environments

Testing 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, and 11)
  • pytest opentelemetry-sdk/tests/metrics/: 373 passed, 1 skipped (Windows-only skip), 0 failures
  • ruff check: all checks passed
  • ruff format --check: all files formatted
  • Changelog entry added in .changelog/5627.fixed

…e same instrument

Fixes open-telemetry#5627

Assisted-by: Google Antigravity
Signed-off-by: Anjali Mishra <246823347+anjalimishra-0007@users.noreply.github.com>
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-13 12:38 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

View identity-conflict warning never fires when the conflicting views match the same instrument

1 participant