feat(hybridcloud): Split backlog metrics by dispatch regime and report depth quantiles - #122035
Open
vaind wants to merge 1 commit into
Open
feat(hybridcloud): Split backlog metrics by dispatch regime and report depth quantiles#122035vaind wants to merge 1 commit into
vaind wants to merge 1 commit into
Conversation
…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
marked this pull request as draft
August 14, 2026 12:20
vaind
marked this pull request as ready for review
August 14, 2026 12:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_rolloutramps, 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_countcarries no regime, so the chart cannot distinguish them.max_depthhas 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) onpending_count,active_count,max_depthandoldest_pending_age_seconds, and a newmailbox.depth_quantilegauge taggedquantile:p50|p90|p99.The regime comes from
use_claim_dispatchrather 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_metricsalready 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: ametrics.distributionper 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_dispatchis a pure rename, no call-site semantics change.Part of CW-1830. Follow-up to #121982.