Skip to content

RFC: Metric Builder Wildcard Name Matching #13358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

braydonk
Copy link
Contributor

@braydonk braydonk commented Jul 8, 2025

Description

This PR is an RFC to allow wildcard name matching in mdatagen metric/resource attribute builder configs. This is needed because of the high number of metrics and resource attributes that need to be controlled in many receivers, making configs extremely dense, hard to follow, and more prone to breakages as metrics/attributes themselves get added or changed.

Link to tracking issue

Originally discussed in #10074

Implementation in #10065. PR is quite outdated now, but the generated matching library is the meat of it.

The grammar is an extension of the OTel name grammar. In plain english, the OTel name gramma is an OTel identifier (characters with underscores) optionally followed by a `.` and another OTel identifier. With the wildcard matching, the grammar is similar, except instead of a name you can optionally have one of two things:

* A wildcard `*` character, which matches anything in a group. If it is the final group, it will match any number of subsequent groups.
* A multimatch `{x,y,z,...}` which will match anything specified within it
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When last discussed, this part of the grammar was in contention. Removing it may simplify the implementation a bit.


### What and Why

The following is a specification for OpenTelemetry Wildcard Name Matching grammar that could be added to the generated `metadata` packages from `mdatagen`. This grammar will facilitate the use of wildcards in metric and resource attribute configurations to enabling/disabling metrics/resource attributes in a more concise way, allowing a configuration like:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably this could be added as a package in the collector repo that the templates import.

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.53%. Comparing base (c4456e0) to head (6e36374).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13358      +/-   ##
==========================================
- Coverage   91.54%   91.53%   -0.02%     
==========================================
  Files         526      526              
  Lines       29434    29434              
==========================================
- Hits        26946    26942       -4     
- Misses       1962     1965       +3     
- Partials      526      527       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bogdan-st
Copy link

Awesome proposal!
One concern I have is that wildcard configurations will be much harder to debug than explicit naming. Have you considered some debugging/validation options? I'm not sure how those would look like(maybe a "dry-run" showing the final priority list or a way to show what matcher matched with x) but my guess is that debugging why x is disabled can get pretty complex.

@braydonk
Copy link
Contributor Author

braydonk commented Jul 9, 2025

@bogdan-st Good idea. This would be technically feasible, and I'll add a section to the RFC that explains how it would look. One thing I'm unsure of is how to actually expose it though. Perhaps as part of the Metric Builder's config validation somehow so that when the Collector config validation is called the dry-run output can be sent to stderr? That part I'm not sure about.

@ChrsMark
Copy link
Member

ChrsMark commented Jul 9, 2025

I support this proposal.

This will allow us to have a generic way for grouping enabled/disabled metrics, sth that today we do through specific settings (i.e. metric_groups) in components like kubeletstatsreceiver. What this proposal suggests is way more flexible.

+1 on providing a way to output what the actual configuration will be after is evaluated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants