-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Sanitize metric names in the prometheus exporter #3212
Sanitize metric names in the prometheus exporter #3212
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3212 +/- ##
=====================================
Coverage 77.3% 77.3%
=====================================
Files 159 159
Lines 11101 11139 +38
=====================================
+ Hits 8583 8617 +34
- Misses 2323 2325 +2
- Partials 195 197 +2
|
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 think this is a good stop gap, but it will iterate through all names on every collect.
We should revisit this and see if there is a way to optimize it so that there is approximately constant time sanitizing the names.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
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.
🥇
Prometheus has different metric restrictions than the specification provides us.
All prometheus metrics must match this regex: https://github.com/prometheus/common/blob/main/model/metric.go#L27
While the specification will use dots in metric names, and therefore cause invalid metric names in the exporter.
See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/process-metrics.md
With this change, libraries can use metric names valid with semantic conventions, for which any invalid character will be replaced with an underscore.
Related: open-telemetry/opentelemetry-go-contrib#2787
Fixes #3183