Skip to content

feat(hybridcloud): Split backlog metrics by dispatch regime and report depth quantiles - #122035

Open
vaind wants to merge 1 commit into
masterfrom
ivandlugos/hybridcloud-backlog-metrics-cohort-split
Open

feat(hybridcloud): Split backlog metrics by dispatch regime and report depth quantiles#122035
vaind wants to merge 1 commit into
masterfrom
ivandlugos/hybridcloud-backlog-metrics-cohort-split

Conversation

@vaind

@vaind vaind commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Tags every webhookpayload.mailbox.* metric with the dispatch regime that would drain the mailbox, and adds a depth distribution alongside the existing max.

Why

While claim_dispatch_rollout ramps, the question the backlog charts are asked is "is the claim cohort's backlog burning down while lease's stays flat?" They cannot answer it. A provider-only rollup averages the two regimes into a single line that describes neither, so the burn-down has to be inferred from a global total whose own variance dwarfs the cohort's contribution — the same problem #121982 fixed for delivery outcomes and latency.

This came out of reading the 50% rollout. The remaining backlog concentrated in one event type, and there was no way to tell whether that was a cohort that had not been treated yet or simply the highest-volume event type draining slowest. pending_count carries no regime, so the chart cannot distinguish them.

max_depth has a related blind spot. It reports the same number whether a single mailbox is stuck at 300 or the provider's entire backlog has shifted deeper, and those want different responses — one is a mailbox to go look at, the other is a capacity problem.

What

mode (claim / lease) on pending_count, active_count, max_depth and oldest_pending_age_seconds, and a new mailbox.depth_quantile gauge tagged quantile:p50|p90|p99.

The regime comes from use_claim_dispatch rather than a restatement of the hash, so the cohort this reports can never drift from the cohort that actually claims. That is why the predicate stops being private — this is the second legitimate caller, and a copied md5 would silently desync the metric from real dispatch the moment the bucketing key changed.

Quantiles are nearest-rank, so every value returned is a depth some mailbox actually has; an interpolated 287.4 names none of them.

Cost

Deliberately small, because the expensive part is already paid. record_mailbox_depth_metrics already aggregates every mailbox under a statement timeout and already walks the per-mailbox depths in memory. The regime tag adds an md5 per row and the quantiles add one sort per (provider, mode) — against a full-table aggregate running every 5 minutes.

Series cost is 2x on the four existing mailbox metrics, plus 3 per (provider, mode) for the quantiles. Reporting quantiles rather than emitting a distribution is what keeps that bounded: a metrics.distribution per mailbox would put a series count proportional to the backlog behind the metric that exists to measure the backlog.

Caveat

The regime is derived per run, not stored, so a rollout change re-attributes existing backlog on the next pass. The tag answers "which regime owns this backlog now", not "which one produced it" — the burn-down curve steps at each rollout change rather than tracking a fixed population. That is the right semantics for the question being asked of it, but it is worth knowing before reading a discontinuity as a regression.

Scope

No behavior change: no query, delivery decision, or claim bound is altered, and the aggregate query is untouched. use_claim_dispatch is a pure rename, no call-site semantics change.

Part of CW-1830. Follow-up to #121982.

…t depth quantiles

The backlog charts cannot say whether the claim cohort's backlog is draining
while lease's stays flat, which is the comparison the claim_dispatch_rollout is
judged on. A provider-only rollup averages the two regimes into one line that
describes neither, so during the ramp the burn-down has to be inferred from a
global total whose own variance dwarfs the cohort's effect.

max_depth has a related blind spot: it reports the same number whether one
mailbox is stuck or the provider's whole backlog has shifted deeper, and those
want different responses.

Both come cheap here. record_mailbox_depth_metrics already aggregates every
mailbox and already walks the per-mailbox depths in memory, so the regime tag
costs an md5 per row and the quantiles cost one sort per (provider, mode) --
against a full-table aggregate that was already being paid every 5 minutes.
Reporting quantiles rather than emitting a distribution keeps this at a fixed
handful of series instead of one per mailbox.

The regime is derived from use_claim_dispatch rather than restated, so what
this reports can never drift from the cohort that actually claims; that is also
why the predicate stops being private.
@vaind
vaind requested a review from a team as a code owner August 14, 2026 12:14
@linear-code

linear-code Bot commented Aug 14, 2026

Copy link
Copy Markdown

CW-1830

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 14, 2026
@vaind
vaind marked this pull request as draft August 14, 2026 12:20
@vaind
vaind marked this pull request as ready for review August 14, 2026 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant