prometheus-community / prom-label-proxy

A proxy that enforces a given label in a given PromQL query.
Apache License 2.0
248 stars 95 forks source link

chore: dont rely on slice labels #184

Closed MichaHoffmann closed 5 months ago

MichaHoffmann commented 5 months ago

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!

squat commented 5 months ago

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

SuperQ commented 5 months ago

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

SuperQ commented 5 months ago

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 commented 5 months ago

@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.

bboreham commented 5 months ago

And soon -tags dedupelabels - https://github.com/prometheus/prometheus/pull/12304