Repository navigation
feat(global-frontend): routing metrics for affinity - #17553
jthomson04 wants to merge 3 commits into
Conversation
|
/ok to test d92d393 |
| } | ||
| } | ||
|
|
||
| /// Adds what the affinity selector `affinity` weighs, from `signals`, and |
There was a problem hiding this comment.
This doc comment only paraphrases with_routing(signals, affinity) and the metrics constructed immediately below; it records no constraint or behavior beyond the code.
🤖 AI Fix
Remove this two-line doc comment.
|
Do you want to raise this against main John? |
✅ Dynamo PR CI passed — run 40931422553 (attempt 1) on
|
b4dbaa9 to
f088c63
Compare
d92d393 to
94a133c
Compare
|
/ok to test 94a133c |
f088c63 to
7c924bc
Compare
94a133c to
eca25d3
Compare
|
/ok to test eca25d3 |
Serve the Global Frontend's own Prometheus families, dynamo_global_frontend_*: requests per pool by response status (with a local label for the in-region share, and cancelled for a client that leaves before the pool answers), requests answered without a pool, time to first byte and duration per pool, responses that broke off, and requests in flight per pool. Series are labelled with the pool's name and region, never with the request's model. Pools now carry a name for people, their <cluster>/<namespace>/<DGD name>. Inter-token latency and token counts need the stream parsed and stay with the pool frontends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
7c924bc to
eb4f370
Compare
|
/ok to test e8b7f09 |
eca25d3 to
e8b7f09
Compare
A Dynamo pool frontend sends its response headers once a worker has the request, so a client that gives up while a worker queues its request counts under the pool's status, not as cancelled. Also note that an SSE keep-alive before the first token counts as the first byte, and list no_response in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
With --router-policy affinity, /metrics also shows what the selector weighs and decides, read at scrape time: each pool's occupancy by slots and KV (absent while unknown), the round trip to each region, each request's outcome for its session's pin (stayed, moved, new, no_session), and the sessions pinned. AffinitySelector counts outcomes in relaxed atomics, so lib/global-router gains no Prometheus dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
|
/ok to test 3f7a1d3 |
e8b7f09 to
3f7a1d3
Compare
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Affinity outcomes and pool labels lib/global-router/src/affinity.rs, lib/global-router/src/pool.rs |
AffinitySelector counts stayed, moved, new, and no_session outcomes. Pool exposes a name built from its cluster, namespace, and DGD name. |
Metric registration and refresh lib/global-frontend/Cargo.toml, lib/global-frontend/src/lib.rs, lib/global-frontend/src/metrics.rs |
Metrics registers request, response, timing, in-flight, and optional routing metrics. Scrapes refresh gauges from pool snapshots and encode the Prometheus registry. |
Proxy instrumentation and endpoint lib/global-frontend/src/main.rs, lib/global-frontend/src/proxy.rs, lib/global-frontend/tests/forwarding.rs, lib/global-frontend/README.md, docs/fern/pages/reference/observability/metrics-catalog.mdx |
The proxy records request outcomes and response timing, and serves metrics at /metrics. The frontend configures metrics, tests check request and routing measurements, and the documentation describes the endpoint and metric families. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Merge Risk: 
Minimal · up to 3f7a1
-
No identified issue blocks merging after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 7 files. (3 skipped: 3 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
⚔️ Resolve merge conflicts: 💡
-
- Resolve merge conflict in branch
jthomson04/global-frontend-routing-metrics
- Resolve merge conflict in branch
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Overview
With
--router-policy affinity, the Global Frontend's/metricsnow shows what the selector weighs and what it decides:Without these, the only way to see why sessions stay or move is the debug logs.
Stacked on #17525, which adds the Global Frontend's traffic metrics. This PR's base is that branch; it will be retargeted to
mainonce #17525 merges.Key Changes
About 130 core lines.
affinity.rs:AffinitySelectorcounts each placed request by what became of its session's pin, when it pins the session, and exposes the counts asselections(). It uses four relaxed atomics, solib/global-routergains no Prometheus dependency.metrics.rs:Metrics::with_routing(signals, selector)adds four families, all read at scrape time.dynamo_global_frontend_pool_occupancy_ratioPoolSignals::occupancy:slotsandkv, 1 being full. A pool has no series while its load is unknown, which the selector treats as full.dynamo_global_frontend_region_round_trip_secondsdynamo_global_frontend_affinity_selections_totalstayed,moved,new(no live pin) orno_session. The share of turns kept on their pool isstayed / (stayed + moved).dynamo_global_frontend_affinity_pinned_sessionsmain.rs: theaffinitypolicy passes its signals and selector to the metrics.README and Metrics Catalog: document the four families.
Validation
new, a repeat on its pool isstayed, a move for more room ismoved; a request without a session isno_sessioncounts_what_became_of_each_sessions_pin/metricsshows slots and KV occupancy for a pool with a report and nothing for one without, the region round trip, outcomes and pinned sessions; counters catch up with the selector at each scrapeshows_what_the_affinity_selector_weighs_and_decidescargo clippy --all-targets -D warningsandcargo testpass fordynamo-global-common,dynamo-global-routeranddynamo-global-frontend.Issues and Ongoing Work
Pull Request Checklist
/pr-checklistskill.🤖 Generated with Claude Code
Summary by CodeRabbit
/metricsendpoint with request counts, response errors, latency, in-flight requests, and routing and affinity measurements.