metrics: allow extra labels on HTTP request/response Prometheus metrics - #31530
Conversation
Add an optional `extra_labels: Optional[Dict[str, str]]` parameter to `add_prometheus_track_response_middleware` that is merged into the label set of the sglang:http_requests_total / http_responses_total / http_requests_active metrics (and their inc/dec calls). This lets a deployment attach identifying labels (e.g. job id, replica id) to HTTP metrics so they can be filtered/joined the same way as the scheduler metrics, without a label-join. Defaults to no extra labels, so existing behavior is unchanged.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 603f91840c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def add_prometheus_track_response_middleware(app): | ||
| def add_prometheus_track_response_middleware( | ||
| app, extra_labels: Optional[Dict[str, str]] = None |
There was a problem hiding this comment.
Pass extra labels from the HTTP server
In the normal HTTP-server launch path, the only in-repo call remains add_prometheus_track_response_middleware(app) in python/sglang/srt/entrypoints/http_server.py:2370, so ServerArgs.extra_metric_labels never reaches this new parameter. Deployments using --extra-metric-labels will still get those labels on scheduler/tokenizer metrics but not on these HTTP counters/gauges, which defeats the new filtering/joining use case this parameter is meant to support.
Useful? React with 👍 / 👎.
Add an optional
extra_labels: Optional[Dict[str, str]]parameter toadd_prometheus_track_response_middlewarethat is merged into the label set of the sglang:http_requests_total / http_responses_total / http_requests_active metrics (and their inc/dec calls). This lets a deployment attach identifying labels (e.g. job id, replica id) to HTTP metrics so they can be filtered/joined the same way as the scheduler metrics, without a label-join. Defaults to no extra labels, so existing behavior is unchanged.Motivation
Modifications
Accuracy Tests
Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #29645532213
Latest PR Test (Extra): ❌ Run #29645532167