-
Notifications
You must be signed in to change notification settings - Fork 148
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
Remove framework-specific route detection from collector middleware #251
Conversation
20a21e7
to
a26ae7d
Compare
Sadly, with the benefit of hindsight, this wasn't a good idea. There are two reasons we're dropping this: - It doesn't play nicely with libraries like `Rack::Builder`, which dispatches requests to different Rack apps based on a path prefix in a way that isn't visible to middleware. For example, when using `Rack::Builder`, `sinatra.route` only contains the parts of the path after the prefix that `Rack::Builder` used to dispatch to the specific app, and doesn't leave any information in the request environment to indicate which prefix it dispatched to. - It turns out framework-specific route info isn't always formatted in a way that looks good in a Prometheus label. For example, when using regex-based route-matching in Sinatra, you can end up with labels that look like `\\/vapes\\/([0-9]+)\\/?`. For a really detailed dive into those two issues, see this GitHub comment: #249 (comment) Signed-off-by: Chris Sinjakli <[email protected]>
a26ae7d
to
e0dd0f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we document this new idea that if you want specific path
labeing, the way to go is subclassing the Collector and adding your class as the middleware instead?
Sure thing. Maybe a slight rearrange of this doc to emphasise that you can customise |
Yeah, that sounds perfect. |
1533fbd
to
1dfc1ad
Compare
Signed-off-by: Chris Sinjakli <[email protected]>
All done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you
Sadly, with the benefit of hindsight, this wasn't a good idea.
There are two reasons we're dropping this:
It doesn't play nicely with libraries like
Rack::Builder
, whichdispatches requests to different Rack apps based on a path prefix in
a way that isn't visible to middleware.
For example, when using
Rack::Builder
,sinatra.route
onlycontains the parts of the path after the prefix that
Rack::Builder
used to dispatch to the specific app, and doesn't leave any
information in the request environment to indicate which prefix it
dispatched to.
It turns out framework-specific route info isn't always formatted in
a way that looks good in a Prometheus label.
For example, when using regex-based route-matching in Sinatra, you
can end up with labels that look like
\\/vapes\\/([0-9]+)\\/?
.For a really detailed dive into those two issues, see this GitHub
comment:
#249 (comment)
Fixes #249