Conversation
…pen-telemetry#5664) The OpenTelemetry Metrics Specification specifies that if name is provided, the View MUST match at most one instrument, and if instrument_name contains wildcard characters (*, ?, [seq], [!seq]), name MUST NOT be provided. Previously, View.__init__ only checked for '*' and '?' in instrument_name, allowing character sequence wildcards such as '[' and ']' (e.g. 'http_[0-9]') to bypass validation when name is set. Update View.__init__ to detect character pattern wildcards ('[', ']') in addition to '*' and '?', and add test coverage for character sequence wildcards. Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
Pull request dashboard statusWaiting on reviewers · refreshed 2026-09-21 20:34 UTC Review the latest changes. Status above doesn't look right?
|
Author
|
/dashboard route:reviewers |
|
@somuai, this pull request was routed to reviewers. The handoff remains active across pushes until newer actionable human feedback arrives. Top-level feedback through this request will not return; unresolved review threads remain open. |
herin049
reviewed
Sep 21, 2026
herin049
left a comment
Contributor
There was a problem hiding this comment.
There appears to be some unrelated formatting changes being applied here.
Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>
Author
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 #5664
According to the OpenTelemetry Metrics Specification for Views (https://opentelemetry.io/docs/specs/otel/metrics/sdk/#view):
Previously,
View.__init__checked for wildcard characters ininstrument_nameonly by inspecting whether"*" in instrument_name or "?" in instrument_name. However, instrument matching inView._matchis executed viafnmatch.fnmatchcase(), which supports character sequence wildcards such as[seq]and[!seq](for example,instrument_name="http_[0-9]"). Because brackets were not checked, specifying a character set wildcard alongside a customnamebypassed the validation check, permitting multiple instruments to match a single renamed View stream in violation of the specification constraint.This change updates
View.__init__to detect character pattern wildcards ("[","]") ininstrument_namein addition to"*"and"?", raising an exception whenevernameis provided with any wildcard pattern.Changes
opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.py:View.__init__wildcard check to verifyany(c in instrument_name for c in "*?[]").opentelemetry-sdk/tests/metrics/test_view.py:test_view_namewith subtests covering*,?,[0-9],[!a-z],[abc],[, and], verifying they raise an exception whennameis provided.instrument_namesucceeds withname..changelog/5664.fixed.Verification
PYTHONPATH=opentelemetry-api/src:opentelemetry-sdk/src:opentelemetry-semantic-conventions/src:tests/opentelemetry-test-utils/src pytest opentelemetry-sdk/tests/metrics/test_view.py opentelemetry-sdk/tests/metrics/test_view_instrument_match.py -vResult: 27 passed, 8 subtests passed (100% green).
Signed-off-by: Soumyajit Ghosh <jobsoumyajit6124@gmail.com>.