-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[axum-extra] metrics
integration?
#2988
Comments
Can you check again https://github.com/Ptrskay3/axum-prometheus? I'm using since years, and it's using |
🤔 Ah, seems I'm encountering Ptrskay3/axum-prometheus#66 because But that does not change the point though, |
And if you plan to use Prometheus, then the Ptrskay3/axum-prometheus#66 actually comes from an unfortunate API in However, you are not stuck with it, it's still possible to drop down lower level APIs of Based on the discussion at this issue, I have a feeling that you're proposing here is probably 80-85% the same thing that Also tangentially related: Ptrskay3/axum-prometheus#66 (comment) |
I don't think I'd want to integrate non-trivial features like this in axum-extra. metrics seem complex enough to be a separate crate. |
For one who may be interested, I published |
Feature Request
Motivation
In #671, we added an example to manually instrument a single endpoint to support metrics. But the boilerplate is quite large for a middleware that wraps all requests track about request or response body, eg. body size, time-to-first-byte, time of round-trip and etc.
Proposal
Add a feature-gated module
metrics
inaxum-extra
to provide aMetricLayer
middleware that instrument all requests and responses withmetrics
, maybe in a configurable way.Since the middleware only does instrumentation, it only depends on
metrics
crate and is generic over export methods. It could be done in a few hundreds of lines, and users are free to customize export methods on their own: push metrics elsewhere, expose prometheus scrape endpoint as a route, or listen on another port for metrics.This solution contrasts to
axum-prometheus
which is strongly coupled with prometheus exporter and does many hard-coded non-trivial things (e.g. always listen onlocalhost:9000
).Alternatives
axum-metrics
. This may be better depending on how many users want this feature.tower-http::metrics
. This would not be easy to use since we almost always want aMatchedPath
label. We could split the instrumentation with a generictrait ExtractLabels
andimpl ExtractLabels
inaxum-extra
. But I doubt whether the increased complexity worth it, and this requires more boilerplate foraxum
users.The text was updated successfully, but these errors were encountered: