-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve performance of pattern matching in OpenMetrics #5764
Conversation
self.TELEMETRY_COUNTER_METRICS_IGNORE_COUNT, len(metric.samples), scraper_config | ||
) | ||
return # Ignore the metric | ||
if scraper_config['_ignored_patterns']: |
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.
nit: you can also wrap if metric.name in scraper_config['_ignored_metrics']
if you change to if config['ignore_metrics']
Just to clarify: I was saying The performant way to do this is calling https://docs.python.org/3/library/fnmatch.html#fnmatch.translate on all patterns, then In the end you just call |
a3d2c79
to
81a67c4
Compare
@ofek yes I got you point and this is not related to |
Out of curiosity, I wanted to bench this good idea (on the Mac + Python 3.7) on a KSM output (320M), time for 10 runs.
Worth changing to this suggestion! |
pushed an attempt with |
@ofek shouldn't we implement a similar logic to match whitelisted metrics? https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/datadog_checks/base/checks/openmetrics/mixins.py#L564 |
Sure! |
ccdec75
to
e9b2e8b
Compare
What does this PR do?
Follow-up on https://github.com/DataDog/integrations-core/pull/5759/files#r380296940
Compile and cache wildcards instead of calling
fnmatchcase
to match metric names.Motivation
Perf improvment
Additional Notes
Review checklist (to be filled by reviewers)
changelog/
andintegration/
labels attached