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

How can I change how paths are labelled? #307

Closed
rquinlivan opened this issue Mar 8, 2024 · 1 comment
Closed

How can I change how paths are labelled? #307

rquinlivan opened this issue Mar 8, 2024 · 1 comment

Comments

@rquinlivan
Copy link

I'm having trouble with Prometheus generating a new label for each request in one part of an application, but others are correctly mapped, e.g. /posts/:post_id/ instead of /posts/12345. I noticed that there is a strip_ids_from_path method and a PATH_INFO env var that seem to allow this to be tuned per application, but no documentation on how this would work. How can i use these options to collapse all the /posts/12345 type labels into /posts:post_id?

@Sinjo
Copy link
Member

Sinjo commented Mar 27, 2024

Hi @rquinlivan 👋🏻

The collector middleware we provide in Prometheus::Middleware::Collector is intended to cater to basic HTTP metric collection needs and doesn't allow customising path filtering or metric labels.

Back when we were preparing for our 1.0 release, we did consider adding some extra options to initialize, to allow customising labels and path handling by passing lambdas to it which would override our default implementations. We quickly realised that once we did that, there was essentially nothing left of our middleware code and it was just invoking lambdas. At that point, we didn't feel that there was any value in using our middleware and it would be better for users of client_ruby to create their own collector middleware in their application's codebase (possibly copying ours as a base).

If you're interested, the original discussion is over at #111 and references the implementation that we scrapped.

Hope that's helpful!

@Sinjo Sinjo closed this as completed Mar 27, 2024
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