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

chore: dont rely on slice labels #184

Conversation

MichaHoffmann
Copy link
Contributor

I wanted to proceed a bit on trying to convert thanos to build with stringlabels and prom-label-proxy is used as a library there. This would fix this build error for me!

@MichaHoffmann MichaHoffmann force-pushed the mhoffm-dont-rely-on-slice-labels branch 2 times, most recently from d63b908 to af48549 Compare January 26, 2024 20:00
@SuperQ SuperQ requested a review from squat January 26, 2024 21:23
@squat
Copy link
Member

squat commented Jan 26, 2024

@MichaHoffmann can you give me a bit more context? How is this code affecting external behavior in the Thanos build?

@SuperQ
Copy link
Contributor

SuperQ commented Jan 27, 2024

@squat There is the new "stringlabels" code in Prometheus itself. When switching to this implementation, accessing the slice directly is no longer allowed.

@SuperQ
Copy link
Contributor

SuperQ commented Jan 27, 2024

Here's what you get if you build prom-label-proxy now:

$ go build --tags=stringlabels .
# github.com/prometheus-community/prom-label-proxy/injectproxy
injectproxy/rules.go:210:24: cannot range over rule.Labels() (value of type "github.com/prometheus/prometheus/model/labels".Labels)
injectproxy/rules.go:234:23: cannot range over alert.Labels (variable of type "github.com/prometheus/prometheus/model/labels".Labels)

With this change, the build is successful.

@MichaHoffmann
Copy link
Contributor Author

@MichaHoffmann can you give me a bit more context? How is this code affecting external behavior in the Thanos build?

What @SuperQ said! Just adding context that I want to convert Thanos to be compatible with the stringlabels tag and there are more build failures, this was just one of them and it seemed easy enough to fix.

Copy link

@bboreham bboreham left a comment

Choose a reason for hiding this comment

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

I’m not a maintainer here but had a comment if efficiency is a concern.

injectproxy/rules.go Outdated Show resolved Hide resolved
Signed-off-by: Michael Hoffmann <[email protected]>
@MichaHoffmann MichaHoffmann force-pushed the mhoffm-dont-rely-on-slice-labels branch from af48549 to 2bd8cbc Compare January 27, 2024 13:05
Copy link
Member

@squat squat left a comment

Choose a reason for hiding this comment

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

Thanks for the context @SuperQ @MichaHoffmann 🏄‍♀️🏄‍♀️🏄‍♀️

@squat squat merged commit c1195f9 into prometheus-community:main Jan 27, 2024
4 checks passed
@bboreham
Copy link

And soon -tags dedupelabels - prometheus/prometheus#12304

SuperQ added a commit that referenced this pull request Jan 27, 2024
Internal change for library compatibility. No user-visible changes.

* [CHANGE] Don't rely on slice labels #184

Signed-off-by: SuperQ <[email protected]>
@SuperQ SuperQ mentioned this pull request Jan 27, 2024
squat pushed a commit that referenced this pull request Jan 27, 2024
Internal change for library compatibility. No user-visible changes.

* [CHANGE] Don't rely on slice labels #184

Signed-off-by: SuperQ <[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

Successfully merging this pull request may close these issues.

4 participants