feat(gateway): add engine-agnostic observability metrics and overhaul Grafana dashboard - #2392
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements to the gateway and model metrics tracking, including the addition of model replica metrics, in-flight request tracking per model, and token usage counters. It also improves the accuracy of streaming metrics like Time to First Token (TTFT) and Time Per Output Token (TPOT). The review feedback highlights two potential metric leak issues: one where a model name change during the request lifecycle could leak in-flight counts, and another where a panic during a prefill request could prevent the outstanding prefill counter from being decremented. Robust code suggestions using dynamic tracking and defer blocks are provided to address these concerns.
2899419 to
eef85c3
Compare
|
@varungup90 there's some conflicts needs to be resolved |
… Grafana dashboard Signed-off-by: varungupta <varungup90@gmail.com>
Signed-off-by: varungupta <varungup90@gmail.com>
Signed-off-by: varungupta <varungup90@gmail.com>
eef85c3 to
4874145
Compare
- Replace atomic-counter + Set() snapshots for gateway_in_flight_requests and gateway_model_in_flight_requests with direct IncGaugeMetric/ DecGaugeMetric calls, matching the prefill-outstanding gauge and avoiding stale-snapshot races under concurrency. - Fix streaming PD decode_time collapsing to ~0: the caller was passing FirstTokenTime itself as requestEndHelper's arrival, so arrival.Sub(FirstTokenTime) always computed zero. Pass the real final chunk arrival instead; TTFT already derives from routingCtx.FirstTokenTime internally. - Emit gateway_tpot_bucket_total for the PD streaming path, which previously only the non-PD branch reported. Signed-off-by: varungupta <varungup90@gmail.com>
8c07d93 to
e16d514
Compare
Signed-off-by: varungupta <varungup90@gmail.com>
Pull Request Description
Summary
gateway_model_in_flight_requests), global in-flight (gateway_in_flight_requests), PD prefill outstanding (gateway_prefill_outstanding_requests), summable token usage (gateway_input_tokens_total,gateway_output_tokens_total,gateway_requests_with_usage_total), and ready engine replica counts (model_replicas).$modelfiltering, parameterized datasource, and collapsed developer internals; remove unused metrics (gateway_e2e_duration_seconds, aggregate success/fail counters,gateway_decode_outstanding_requests).Details
Gateway Plugin
has_usagecounter when usage is present in responses.RoutingContext.FirstTokenTimeon the first streamed body chunk and propagatingStreamfrom the request body handler.role-namepod label (fallback:ROLE_NAMEenv) for metric labels.Cache
model_replicas=1for each ready, routable engine pod (HTTP server on pod group index0), with stale-series cleanup when pods leave the cache.PD Disaggregation
gateway_prefill_outstanding_requestsaround prefill RPCs.Prefix Cache
_init_instead of an empty model label for indexer status metrics.Grafana
$modeltemplate variable support.Related Issues
Resolves: #[Insert issue number(s)]
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]: Corrections to existing functionality[CI]: Changes to build process or CI pipeline[Docs]: Updates or additions to documentation[API]: Modifications to aibrix's API or interface[CLI]: Changes or additions to the Command Line Interface[Misc]: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.