fix(telemetry): add wildcard-aware instrument name matcher for metric views#9809
Open
apollo-mateuswgoettems wants to merge 5 commits into
Open
fix(telemetry): add wildcard-aware instrument name matcher for metric views#9809apollo-mateuswgoettems wants to merge 5 commits into
apollo-mateuswgoettems wants to merge 5 commits into
Conversation
… views The OpenTelemetry 0.31 View API migration replaced the SDK pattern-aware view selection with a closure doing exact string comparison, so wildcard (*, ?) and catch-all view names silently stopped matching. Add a shared InstrumentNameMatcher (regex-backed) and route into_view_fn through it.
…f exact-name map Build user views into an ordered Vec of (matcher, view) and select by first match instead of an exact-name HashMap lookup, so wildcard and catch-all patterns apply again and declaration order controls precedence.
This comment has been minimized.
This comment has been minimized.
Contributor
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: e92649675b37cb051e190048 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
apollo-mateuswgoettems
requested review from
aaronArinder
and removed request for
aaronArinder
July 14, 2026 19:48
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.
Motivation
Since v2.13.0 (the OpenTelemetry SDK 0.24 → 0.31 migration), metric views configured under
telemetry.exporters.metrics.common.viewsonly match instruments by exact name. Wildcard patterns (cost.*), single-character wildcards (?), and catch-all names (*or an empty string) — all of which the pre-0.31 SDK matched natively — silently stopped matching.Concretely, a config like:
no longer applied the custom buckets to
cost.*metrics and no longer dropped the unlisted metrics, leaking 80+ router-internal metrics to the exporter. This was reported by a user who relied on this exact pattern before upgrading from v2.11.0.Root cause
The 0.31 migration replaced the SDK's pattern-aware
new_view(Instrument, Stream)(which matched instrument-name selectors with*/?wildcards natively) with a closure that does a plaininstrument.name() != namecomparison, andresolve_viewlooked user views up in aHashMap<String, MetricView>keyed by exact name. Neither replicated the wildcard matching the SDK used to provide, so every wildcard/catch-all pattern silently fell through.What changed
InstrumentNameMatcher(backed byregex, already a dependency — no new crate) that restores the semantics: escape the name, translate*→.*and?→.into an anchored pattern; an empty name or a bare*matches everything; names without a wildcard match exactly. Any other character (including.) stays literal.MetricView::into_view_fnandresolve_view— now route through the matcher, so the wildcard behavior can't silently diverge between them again (the pre-fix wiring had already oscillated between these two paths across releases).configure_viewsbuilds an orderedVec<(matcher, view)>andresolve_viewselects by first match instead of aHashMaplookup, so users can place more-specific views before wildcards to control precedence.No configuration schema change → no migration and no breaking config change. This restores the behavior the documentation already describes.
How to verify
http.server.*wildcard, and internal metrics dropped by the catch-all (62 → 19 exported metric families).Checklist
Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.
Notes
Footnotes
It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this. ↩
Configuration is an important part of many changes. Where applicable please try to document configuration examples. ↩
A lot of (if not most) features benefit from built-in observability and
debug-level logs. Please read this guidance on metrics best-practices. ↩Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions. ↩