Add per-route request metrics to the API server#69449
Closed
jayachandrakasarla wants to merge 2 commits into
Closed
Add per-route request metrics to the API server#69449jayachandrakasarla wants to merge 2 commits into
jayachandrakasarla wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #66792
The API server emits process-level metrics but nothing per-route, so operators can't see request rate, latency, or error rate for individual endpoints.
This adds an ASGI middleware that records a counter and a latency histogram per completed request, tagged with the templated route, HTTP method, and status. The templated route (/api/v2/dags/{dag_id}/dagRuns) is used as the tag so per-dag_id requests don't explode metric cardinality.
Metrics go through the existing Stats backend, so they work with StatsD, Datadog, and OpenTelemetry. The middleware is only wired in when a metrics backend is enabled, so deployments without one doesn't export these.
Metrics from
/metricsendpoint of otel collector running on port 28889Screenshots of PromQL queries:



And here's the screenshot of custom metrics dashboard on Grafana:

Was generative AI tooling used to co-author this PR?