-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
mdatagen: add wildcard name matching for configs #10065
base: main
Are you sure you want to change the base?
Conversation
026ad18
to
2ed7ec4
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10065 +/- ##
==========================================
- Coverage 92.59% 92.43% -0.16%
==========================================
Files 387 387
Lines 18198 18264 +66
==========================================
+ Hits 16850 16883 +33
- Misses 1007 1031 +24
- Partials 341 350 +9 ☔ View full report in Codecov by Sentry. |
I think that code coverage change is fine here because none of the |
The changelog issue can only be resolved once the issue is moved from |
cmd/mdatagen/templates/match.go.tmpl
Outdated
"strings" | ||
) | ||
|
||
var ErrNotMultimatch = errors.New("this index doesn't represent a valid multimatch pattern") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason to export any API in this file. We should only export config field types and Unmarshal
methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of the API is exported in the rewrite 3f0a4e8
for _, name := range matchNames { | ||
if pattern.Match(name) { | ||
matched = append(matched, name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fail unmarshalling if we run into a pattern that doesn't match any metric names. It'll be aligned with the strict matching behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add this in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d82df38
cmd/mdatagen/templates/match.go.tmpl
Outdated
patternScan.idx += 2 | ||
} | ||
|
||
case '{': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please point to some specifications for this sort of pattern matching? Does it usually go with wildcard matching?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in the description of the PR, but link here: https://gist.github.com/braydonk/ccb6775331fdd5dca91a650330b9839f
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
@braydonk, are you still working on this? Just checking. Let me know if you have any concerns with my comments |
Hi @dmitryax yes I am. I realized that I forgot to mention that I am writing a full spec to explain how it works, and while I was doing that found a number of edge cases that prompted me to rewrite the parser. Taking longer than expected. I am still working on this though and will keep it unstale. |
This PR adds support for wildcard name matching. Generated MetricsConfig and ResourceAttributesConfig will now support providing names not just as full names, but also using `*` wildcards and multimatching with `{x,y,etc}`. This allows you to apply configs to groups of metrics and resource attributes, simplifying configs. Signed-off-by: braydonk <braydonk@google.com>
What the actual errors look like from collector output is not super obvious from the PR, so here are some examples. I used the hostmetrics process scraper in my example. Not matching any names with the patterns hostmetrics:
collection_interval: 10s
scrapers:
process:
metrics:
"nothing.*":
enabled: false
Parsing errors in a pattern hostmetrics:
collection_interval: 10s
scrapers:
process:
metrics:
"a_.*":
enabled: false
|
I'm gonna wait to address the conflicts, cause this is just going to keep coming up continuously throughout the review. |
Description
This PR adds support for wildcard name matching.
Generated MetricsConfig and ResourceAttributesConfig will now support providing names not just as full names, but also using
*
wildcards and multimatching with{x,y,etc}
. This allows you to apply configs to groups of metrics and resource attributes, simplifying configs.Link to tracking issue
Fixes #10074
Testing
I
go install
ed mdatagen from this PR and ran it on a receiver inopentelemetry-collector-contrib
and was able to use wildcard matching to enable/disable groups of metrics as expected.Documentation
I have written a specification in a gist: https://gist.github.com/braydonk/ccb6775331fdd5dca91a650330b9839f
I am not sure where this documentation should live.