fix(sdk): make instrumentation scope glob matching case-sensitive - #5584
Open
ocelotl wants to merge 2 commits into
Open
fix(sdk): make instrumentation scope glob matching case-sensitive#5584ocelotl wants to merge 2 commits into
ocelotl wants to merge 2 commits into
Conversation
_scope_name_matches_glob used fnmatch.fnmatch, which normalizes both the scope name and the glob pattern through os.path.normcase. On Windows normcase lower-cases its argument, so scope name matching was case-insensitive there while staying case-sensitive on Linux. The same configuration therefore disabled a different set of instrumentation scopes depending on the host operating system. The declarative configuration schema requires case-sensitive matching for the tracer, meter and logger configurator name matchers. Use fnmatchcase so the behavior no longer depends on the host platform, matching what metrics/_internal/view.py and trace/_sampling_experimental/_rule_based.py already do. Fixes open-telemetry#5583.
Pull request dashboard statusWaiting on the author · refreshed 2026-08-25 10:15 UTC Investigate required status check failures. Status above doesn't look right?
|
xrmx
approved these changes
Aug 25, 2026
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 #5583.
_scope_name_matches_globinopentelemetry-sdk/src/opentelemetry/sdk/util/instrumentation.pyusedfnmatch.fnmatch, which normalizes both the scope name and the glob pattern throughos.path.normcase. On Windowsnormcaselower-cases its argument, so instrumentation-scope name matching was case-insensitive there while staying case-sensitive on Linux.That predicate backs scope name matching for the tracer, meter and logger configurators, so the host platform leaked into observable SDK behavior: the same configuration disabled a different set of scopes depending on the operating system.
The declarative configuration schema requires the opposite. From
ExperimentalTracerMatcherAndConfig.nameinopentelemetry-configuration/src/opentelemetry/configuration/schema.json(the meter and logger matchers carry the same wording):This switches the predicate to
fnmatchcase, which is what the rest of the SDK already does.opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/view.pyandopentelemetry-sdk/src/opentelemetry/sdk/trace/_sampling_experimental/_rule_based.pyboth usefnmatchcase, andview.pyalready documents the reason: "fnmatchcase is used instead of fnmatch so it does not rely on the host platform's filename case sensitivity (normcase)".Reported by @lzchen while reviewing #5418: #5418 (comment)
Type of change
How Has This Been Tested?
Added two tests next to the existing
_scope_name_matches_globtests inopentelemetry-sdk/tests/metrics/test_metrics.py:test_scope_name_matches_glob_is_case_sensitive_on_every_platform: a scope name that differs from the pattern only by case must not match, for both an exact pattern and a wildcard pattern.test_scope_name_matches_glob_pattern_case_is_not_normalized: an upper-case pattern must not match a lower-case scope name.Both assertions fail on Windows with
fnmatchand pass withfnmatchcase. On Linux they pass either way, so I confirmed the regression coverage by runningfnmatchandfnmatchcasewithos.path.normcasepatched tontpath.normcase:The repository's Windows CI jobs cover the real case.
Local runs:
pytest opentelemetry-sdk/tests/metrics opentelemetry-sdk/tests/logs opentelemetry-sdk/tests/trace— 705 passedpytest opentelemetry-configuration/tests— 381 passedruff checkandruff format --checkon both changed files — cleanDoes This PR Require a Contrib Repo Change?
Checklist: