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

LabelSet.String sorts incorrectly #543

Open
bboreham opened this issue Dec 1, 2023 · 2 comments
Open

LabelSet.String sorts incorrectly #543

bboreham opened this issue Dec 1, 2023 · 2 comments
Assignees

Comments

@bboreham
Copy link
Member

bboreham commented Dec 1, 2023

This code:

common/model/labelset.go

Lines 135 to 138 in 1d8c672

lstrs = append(lstrs, fmt.Sprintf("%s=%q", l, v))
}
sort.Strings(lstrs)

will sort foo2="bar" before foo="bar".

The usual sort order of Prometheus labels is alphabetical by names, which would put foo before foo2.

@wasim-nihal
Copy link
Contributor

@bboreham , I would like to work in this issue. Can you please assign this to me?

@bboreham
Copy link
Member Author

Sure, thanks for your interest. It would be good to have a small benchmark, to check that your changes run at about the same speed.

wasim-nihal added a commit to nokia/prometheus-common that referenced this issue Feb 2, 2024
wasim-nihal added a commit to nokia/prometheus-common that referenced this issue Feb 8, 2024
wasim-nihal added a commit to nokia/prometheus-common that referenced this issue Feb 8, 2024
wasim-nihal added a commit to nokia/prometheus-common that referenced this issue Feb 9, 2024
SuperQ pushed a commit that referenced this issue Feb 29, 2024
* custom sorting for LabelSet. See: #543

Signed-off-by: Syed Nihal <[email protected]>

* implement custom sorting for prometheus labelset. see: #543

Signed-off-by: Syed Nihal <[email protected]>

* implement custom sorting for prometheus labelset. see: #543

Signed-off-by: Syed Nihal <[email protected]>

* fix sorting issue of prometheus labelset. see: #543

Signed-off-by: Syed Nihal <[email protected]>

---------

Signed-off-by: Syed Nihal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants