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.
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
fnmatchcaseto match metric names.Motivation
Perf improvment
Additional Notes
Review checklist (to be filled by reviewers)
changelog/andintegration/labels attached