Skip to content

Sort by label keys before generating labels key and value lists#3698

Merged
ocelotl merged 13 commits intoopen-telemetry:mainfrom
soundofspace:Fix-bug-when-labels-are-ordered-differently
Apr 17, 2024
Merged

Sort by label keys before generating labels key and value lists#3698
ocelotl merged 13 commits intoopen-telemetry:mainfrom
soundofspace:Fix-bug-when-labels-are-ordered-differently

Conversation

@soundofspace
Copy link
Copy Markdown
Contributor

@soundofspace soundofspace commented Feb 22, 2024

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?

@soundofspace soundofspace requested a review from a team February 22, 2024 10:14
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Feb 22, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@ocelotl
Copy link
Copy Markdown
Contributor

ocelotl commented Mar 7, 2024

Can you please add a test case?

@ocelotl ocelotl added the bug Something isn't working label Mar 7, 2024
@ocelotl
Copy link
Copy Markdown
Contributor

ocelotl commented Mar 7, 2024

@lzchen

Copy link
Copy Markdown
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog entry and a test for this.

@ocelotl
Copy link
Copy Markdown
Contributor

ocelotl commented Mar 14, 2024

@soundofspace this PR needs a test case, marking it as a draft until it has been added.

@ocelotl ocelotl marked this pull request as draft March 14, 2024 21:59
@soundofspace soundofspace marked this pull request as ready for review March 22, 2024 15:32
Copy link
Copy Markdown
Contributor

@xrmx xrmx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given it's a trivial change and still an improvement compared to the actual code for some use cases LGTM

@soundofspace soundofspace requested a review from lzchen April 17, 2024 10:21
Copy link
Copy Markdown
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please fix failing build.

@soundofspace
Copy link
Copy Markdown
Contributor Author

@lzchen not really sure why that build is failing because of this pr, seems like something unrelated to this, and not really sure how to fix it.

@ocelotl
Copy link
Copy Markdown
Contributor

ocelotl commented Apr 17, 2024

@lzchen not really sure why that build is failing because of this pr, seems like something unrelated to this, and not really sure how to fix it.

Probably we just need to update the contrib test SHA, no worries, I have done so.

@ocelotl ocelotl merged commit b51a6f8 into open-telemetry:main Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants