Skip to content

Conversation

alecmerdler
Copy link

Adds WithCustomOption() func which allows
setting arbitrary key/value pairs to the URL
query parameters of the request.

The primary use case for this is to work with
https://github.com/prometheus-community/prom-label-proxy.

Adds 'WithCustomOption()' func which allows
setting arbitrary key/value pairs to the URL
query parameters of the request.

The primary use case for this is to work with
https://github.com/prometheus-community/prom-label-proxy.

Signed-off-by: Alec Merdler <[email protected]>
@alecmerdler alecmerdler force-pushed the support-arbitrary-query-params branch from 7a81563 to d46b13d Compare June 30, 2025 16:38
@alecmerdler
Copy link
Author

This is a naive approach, I will be happy to update the pull request with any feedback. But as it stands today, the official Prometheus client cannot be used with prom-label-proxy.

@kakkoyun
Copy link
Member

@alecmerdler Let's open an issue and discuss this further before jumping into any conclusions.

I would love to learn more about your use cases, especially.

@bwplotka
Copy link
Member

Thanks!

But as it stands today, the official Prometheus client cannot be used with prom-label-proxy.

Are we sure? Would custom roundtripper be possible for those use cases? We could add example how to write one - should be trivial to write one that appends parameters to the query for all requests. Similar to

func (u userAgentRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {

Perhaps hacky, but for advanced use cases should be enough.

Otherwise adding WithCustomOption would mean:

  • There are many ways of doing the same thing (WithStats vs WithCustomOptions("stats", ...) vs roundtripper )
  • In the next PR someone proposes WithCustomOptions to every other method.. which is not simple (Option has other stuff).

Generally as we repeat on every API contribution.. it's NOT a perfect API interface. We learned a lot. It's time for a new one, ideally auto-generated (prometheus/prometheus#2392 (comment)). Given that, I would say roundtripper should suffice, WDYT?

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.

3 participants