opentelemetry-python
opentelemetry-python copied to clipboard
Prometheus exporter should handle metric label key collisions
As described in the spec
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.
Right now this is not happening. The following code
counter = meter_provider.get_meter("scope").create_counter(
"test_with_collision"
)
counter.add(1, {"hello_world": "hello_world", "hello.world": "hello.world"})
expected
# HELP test_with_collision_total
# TYPE test_with_collision_total counter
test_with_collision_total{hello_world="hello.world;hello_world"} 1.0
actual
# HELP test_with_collision_total My description
# TYPE test_with_collision_total counter
test_with_collision_total{hello_world="hello_world"} 1.0