Skip to content
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

Prometheus exporter: Handle attribute key collisions from sanitization #2290

Closed
dashpole opened this issue Sep 1, 2023 · 0 comments · Fixed by #2326
Closed

Prometheus exporter: Handle attribute key collisions from sanitization #2290

dashpole opened this issue Sep 1, 2023 · 0 comments · Fixed by #2326
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@dashpole
Copy link
Contributor

dashpole commented Sep 1, 2023

Is your feature request related to a problem?

From https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#metric-attributes,

OpenTelemetry Metric Attributes MUST be converted to Prometheus labels. String Attribute values are converted directly to Metric Attributes, and non-string Attribute values MUST be converted to string attributes following the attribute specification. Prometheus metric label keys are required to match the following regex: [a-zA-Z_]([a-zA-Z0-9_])*. Metrics from OpenTelemetry with unsupported Attribute names MUST replace invalid characters with the _ character. Multiple consecutive _ characters MUST be replaced with a single _ character. This may cause ambiguity in scenarios where multiple similar-named attributes share invalid characters at the same location. In such unlikely cases, if multiple key-value pairs are converted to have the same Prometheus key, the values MUST be concatenated together, separated by ;, and ordered by the lexicographical order of the original keys.

Describe the solution you'd like

One solution is to group colliding keys, and then join them with ;, like the go exporter does:
https://github.com/open-telemetry/opentelemetry-go/blob/02616a25c68e674a04df01a1b7ba185a2db8cd5a/exporters/prometheus/exporter.go#L284-L305

Another solution is to sort the keys first, and then check whether it collides with the key from the previous iteration, like i'm working on in java: open-telemetry/opentelemetry-java#5717

@github-actions github-actions bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 1, 2023
@marcalff marcalff added bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 6, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 23, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 23, 2023
punya added a commit to punya/opentelemetry-cpp that referenced this issue Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants