Repository navigation
feat(metrics): attach trace exemplars to the inference latency histogram - #541
Conversation
llm_d_async_async_inference_latency_time_millis now carries the request's trace as an exemplar when the trace is sampled: trace_id, plus span_id of the process-request span. Exemplars only reach a scrape over OpenMetrics, and controller-runtime v0.22 builds the /metrics handler without it and has no option to change that. The metrics server's FilterProvider now serves /metrics from a promhttp handler with EnableOpenMetrics, with the auth filter still in front when --metrics-endpoint-auth is on. Scrapers that don't ask for OpenMetrics get the classic format. Part of llm-d/llm-d-router#3584. Signed-off-by: Sohom Chakraborty <16609933+sohom-cs@users.noreply.github.com>
Signed-off-by: Sohom Chakraborty <16609933+sohom-cs@users.noreply.github.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
) * deps(go): bump controller-runtime to v0.25.3 and k8s.io to v0.37.0 controller-runtime v0.25.2 added metricsserver.Options.HandlerOpts, which lets the metrics server enable OpenMetrics (needed for trace exemplars, see #541) without replacing the /metrics handler. v0.25 requires the k8s.io v0.37 libraries, which dependabot does not propose because it skips Kubernetes minor versions. No code changes were needed. ENVTEST_K8S_VERSION follows k8s.io/api, so envtest now runs against Kubernetes 1.37. Signed-off-by: Jacob Murry <jacobmurry@google.com> * deps(go): take k8s.io v0.37.2 Two patch releases are out, and llm-d-router is on v0.37.2, so this keeps one k8s.io line across the two repos. Signed-off-by: Jacob Murry <jacobmurry@google.com> --------- Signed-off-by: Jacob Murry <jacobmurry@google.com>
|
@sohom-cs On your offer to switch to opts := metricsserver.Options{
BindAddress: fmt.Sprintf(":%d", serverCfg.MetricsPort),
HandlerOpts: []func(*promhttp.HandlerOpts){
func(o *promhttp.HandlerOpts) { o.EnableOpenMetrics = true },
},
}
if serverCfg.MetricsEndpointAuth {
opts.FilterProvider = filters.WithAuthenticationAndAuthorization
}That should let |
| `_total`. On Prometheus 2.x, an OpenMetrics scrape stores whole-number bucket | ||
| bounds as `le="10.0"` rather than `le="10"` (Prometheus 3 stores `10.0` either | ||
| way), which only matters to queries that match `le` exactly. |
There was a problem hiding this comment.
This caveat is right, but the repo already documents one exact le match that it breaks: the deadline proximity histogram says le="0" holds items past their deadline. After this change, Prometheus 2.x stores that bucket as le="0.0", so an alert on le="0" silently returns nothing. Please name it here, and ideally fix the deadline proximity row in the metrics table too.
Suggest:
which only matters to queries that match `le` exactly, such as
`le="0"` on `llm_d_async_async_deadline_proximity_millis`, which becomes `le="0.0"`.There was a problem hiding this comment.
Done in 1915573: the caveat now names le="0" on llm_d_async_async_deadline_proximity_millis, which becomes le="0.0", in your wording. The deadline proximity row says le="0.0" too, or le="0" when Prometheus 2.x scrapes the classic text format, and the release note warns about that query.
| [OpenTelemetry Tracing](#opentelemetry-tracing)). Grafana turns it into a link | ||
| from a point on a latency panel to that trace when the Prometheus data source has | ||
| an exemplar link to the traces backend. |
There was a problem hiding this comment.
The dashboard this chart ships (Async Processor, under the chart's dashboards) has no inference latency panel, and none of its queries turn on exemplars. So someone who installs the chart has no "point on a latency panel" to click, which is the motivation the PR gives. Could you add an inference latency quantile panel to that dashboard with exemplars enabled on its query? If you'd rather keep it out of scope, please say here that the bundled dashboard doesn't show it yet.
There was a problem hiding this comment.
Also need to add to the dashboard in the llm-d repo. https://github.com/llm-d/llm-d/blob/main/guides/recipes/observability/grafana/dashboards/llm-d-async-processor.json
There was a problem hiding this comment.
Added in 1915573: the chart's dashboard has an Inference Latency (p50 / p95 / p99) panel with exemplars on the p99 query only, since the three quantiles read the same buckets and enabling all three would draw every exemplar three times. The llm-d dashboard already has that panel without exemplars; the one-line PR that turns them on for its p99 query is open on llm-d/llm-d and links back here.
|
@sohom-cs when will you be able to address the latest feedback on this PR? |
Brings in controller-runtime v0.25.3, whose metrics server options take HandlerOpts, for the review change that follows. Two conflicts: - pkg/metrics/metrics.go imports: this branch added context, main added slices; both are kept. - pkg/server/runner.go: main gave initInferenceClient a WorkerConfig parameter next to this branch's metricsServerOptions; both are kept. Signed-off-by: Sohom Chakraborty <16609933+sohom-cs@users.noreply.github.com>
Review on llm-d#541: with controller-runtime v0.25.3 on main, the metrics server options turn on EnableOpenMetrics for the /metrics handler that controller-runtime builds, as the EPP's newMetricsServerOptions does. That replaces the FilterProvider wrapper in openmetrics.go and its test for other paths. With --metrics-endpoint-auth, FilterProvider is filters.WithAuthenticationAndAuthorization again; the auth test checks that wiring and is renamed TestMetricsServerKeepsAuth. Also from the review: - The chart's dashboard gets an inference latency panel with exemplars on its p99 query. The three quantiles read the same buckets, so only one of them shows exemplars. - docs/observability.md names le="0" on the deadline proximity histogram as a query that OpenMetrics scrapes on Prometheus 2.x turn into le="0.0", and the histogram's row in the metrics table and the release note say so. Signed-off-by: Sohom Chakraborty <16609933+sohom-cs@users.noreply.github.com>
|
Done in 1915573, on top of a merge of main: |
|
lgtm, thanks @sohom-cs ! |
What does this PR do?
Adds a trace exemplar to
llm_d_async_async_inference_latency_time_millis, the async processor's row of item 2 in llm-d/llm-d-router#3584. When the request's trace is sampled, each observation carries itstrace_idand thespan_idof itsprocess-requestspan. The helper follows llm-d-router'sObserveWithTraceExemplar, cut down to this histogram, with the same label names.The classic text format has no exemplars, so the metrics server now enables OpenMetrics through controller-runtime's
Options.HandlerOpts, as the EPP'snewMetricsServerOptionsdoes. Scrapers that don't ask for OpenMetrics get the classic format, and--metrics-endpoint-authworks as before. No series is renamed, since every counter already ends in_total. On Prometheus 2.x, an OpenMetrics scrape stores whole-number bucket bounds asle="10.0", so a query onle="0"ofllm_d_async_async_deadline_proximity_millisneedsle="0.0";docs/observability.mdsays so.The chart's dashboard gets an inference latency panel with exemplars on its p99 query. llm-d's copy of the dashboard gets the same toggle in llm-d/llm-d#3140.
Why is this change needed?
So a slow point on the inference latency panel opens the trace behind it, as the EPP's latency histograms have since llm-d/llm-d-router#2774.
How was this tested?
Unit tests added/updated
Integration/e2e tests added/updated
Manual testing performed
pkg/metrics: a recording span gives both IDs, a propagated sampled one onlytrace_id, an unsampled one or none no exemplar (the cases of observability: add exemplars to tokenizer render latency llm-d-router#4069).pkg/asyncworker: a request throughWorkerleaves an exemplar naming itsprocess-requestspan. It fails on main.pkg/server: the metrics server built fromstartMetricsServer's options serves the exemplar to an OpenMetrics scrape and the classic format to a classic one; with auth on, a scrape without a token gets 401.go test -raceon the three packages,make test,make test-integrationand golangci-lint on the changed code pass.Not run: Grafana against a Prometheus that stores exemplars.
The tests are larger than the code because each step is checked on its own: the helper, the worker's call and the scrape.
Checklist
git commit -s) per DCOmake test)Related Issues
Part of llm-d/llm-d-router#3584
Release note