open-telemetry / open-telemetry/opentelemetry-python
Prometheus exporter should handle metric label key collisions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 19
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Prometheus exporter path that converts metric attribute names, then reproduce the collision using the counter example in the issue. Done means colliding keys produce one label whose values are concatenated with ; in lexicographical order, matching the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- prometheus, python
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100