Sort by label keys before generating labels key and value lists by soundofspace · Pull Request #3698 · open-telemetry/opentelemetry-python
Description
Fixes bug where labels are wrongfully assigned to values because their order changed in input dictionary.
Fixes part of #3391. This does not fix missing labels, it only fixes the issue of labels being wrongfully assigned even if all labels are present (also empty string label values).
Type of change
Please delete options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Test metric:
test_counter.add(1, {'cause': 'cause1', 'reason': 'reason1'})
test_counter.add(1, {'reason': 'reason2', 'cause': 'cause2'})
Before:
# HELP test_counter_total counter used for testing
# TYPE test_counter_total counter
test_counter_total{cause="reason1",reason="cause1"} 1.0
# HELP test_counter_total counter used for testing
# TYPE test_counter_total counter
test_counter_total{cause="cause2",reason="reason2"} 1.0
After:
# HELP test_counter_total counter used for testing
# TYPE test_counter_total counter
test_counter_total{cause="cause1",reason="reason1"} 1.0
test_counter_total{cause="cause2",reason="reason2"} 1.0
Does This PR Require a Contrib Repo Change?
- No.
Checklist:
- Followed the style guidelines of this project
- Changelogs have been updated -> where?