Skip to content

feat(hybridcloud): Tag webhook backlog depth by event type - #121601

Merged
vaind merged 1 commit into
masterfrom
feat/webhook-backlog-by-event-type
Aug 10, 2026
Merged

vaind merged 1 commit into
masterfrom
feat/webhook-backlog-by-event-type

Conversation

@vaind

@vaind vaind commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Problem

The mailbox gauges from #121506 report the backlog per provider — who sent the queued webhooks, not what they are. Sizing a parser-side drop needs the latter.

#121434 dropped 13.6M unconsumed check_suite deliveries a day. The follow-up it names — dropping check_run.completed payloads that reference no pull request based in their own repo, the largest remaining line at 12.1M/day — has an inflow number (github.webhook.forwarded_event) and a latency number (delivery_time_ms{github_event_and_action}), but nothing that says what is actually sitting in the mailboxes. That is the INC-2324/INC-2421 question, and today it is only answerable per provider.

Changes

hybridcloud.webhookpayload.mailbox.pending_count gains an event_type tag.

GitHub mailboxes already carry the answer. GithubRequestParser.get_mailbox_identifier appends the event type to the mailbox name so deliveries of different types don't queue behind each other (GithubEnterpriseRequestParser inherits it), and the aggregate already groups by mailbox_name. So this is a re-key of rows that are in memory either way — no extra query, no change to the statement-timeout envelope.

Two things the derivation has to get right:

  • A delivery that arrives with no X-GitHub-Event header mailboxes without the suffix, leaving a bucket number where this reads. Tagging that verbatim would put unbounded ints in a tag, so only names in CELL_PROCESSED_GITHUB_EVENTS are trusted; anything else is unknown.
  • none (provider doesn't mailbox by event type) is kept distinct from unknown (it does, but this mailbox has none to read). Conflating them would hide the header-less deliveries.

It reads the provider column rather than the mailbox prefix, so legacy rows predating that column report none even when they are GitHub mailboxes. Those are draining out, and deriving a provider two different ways is worse than under-reporting them.

Why only pending_count

Every emission is host-tagged by the Datadog backend, so each tag value costs a series per worker that runs the task. Tagging all four gauges would take this from 4 × 7 providers to 4 × 25 combinations; confining it to pending_count makes that 3 × 7 + 25.

The other three read fine per provider:

  • max_depth — GitHub mailboxes are per-event-type by construction, so this is already one event type's mailbox. The tag would only name which one, and pending_count names it.
  • active_count — a routing/fan-out signal, not a composition one.
  • oldest_pending_age_seconds — a single stalled event type does hide inside the provider-wide age. That is an alerting concern for INC-2421 and a one-line addition if that work wants it; not worth paying for speculatively.

Kept the full 9-event set rather than a hardcoded high-volume subset with an other bucket. That would be cheaper, but the list would go stale silently and hide the next check_suite — the exact thing this exists to catch. The 9 are bounded and grow only when someone adds a GithubWebhookType.

Compatibility

Summing pending_count over event_type reproduces the provider-only value, so anything built on the existing series keeps working. No in-repo consumers reference these metric names.

The mailbox gauges from #121506 report the backlog per provider — who sent
the queued webhooks, not what they are. Sizing a parser-side drop needs the
latter: #121434 dropped 13.6M unconsumed check_suite deliveries a day, and
the follow-up it names, dropping check_run.completed payloads that reference
no pull request in their own repo, has no backlog number behind it yet.

GitHub mailboxes already carry the answer — get_mailbox_identifier appends
the event type so deliveries of different types don't queue behind each
other — and the aggregate already groups by mailbox_name. The dimension is a
re-key of rows already in memory, so it costs no extra query.

Only pending_count gets the tag. Every emission is host-tagged by the
Datadog backend, so each value costs a series per worker that runs the task,
and the other three gauges read fine per provider: GitHub mailboxes are
per-event-type by construction, so max_depth is already one event type's
mailbox and pending_count names which one.

Summing pending_count over event_type reproduces the provider-only value, so
anything built on the existing series keeps working.
@vaind
vaind requested a review from a team as a code owner August 10, 2026 10:13
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 10, 2026
@vaind
vaind requested a review from joseph-sentry August 10, 2026 10:21
@vaind
vaind merged commit a7b500a into master Aug 10, 2026
66 checks passed
@vaind
vaind deleted the feat/webhook-backlog-by-event-type branch August 10, 2026 12:09
vaind added a commit that referenced this pull request Aug 10, 2026
### Why

The [Hybrid Cloud Webhook
Forwarding](https://app.datadoghq.com/dashboard/tqt-8cb-xmj/hybrid-cloud-webhook-forwarding)
dashboard has a `provider` template variable, but
`deliver_webhooks.{delivery,saved,failure}` carry no such tag — only the
`webhookpayload.mailbox.*` gauges do. Verified against Datadog:
`sum:...delivery{*} by {provider}` returns zero series.

So selecting a provider does not filter those widgets, it **blanks**
them, which reads as "no traffic" rather than "this metric cannot answer
that question".

It also makes per-provider delivery health answerable at all. The 401s
and 409s behind `failure` are ~376k/day between them and there is
currently no way to see which integration they belong to.

### Where provider comes from

From the payload column wherever a row is loaded. Two paths have no row:

- **the push trigger** — `maybe_trigger_drain` only receives a mailbox
name
- **the DoesNotExist race** — the row is already gone

Both read the first segment of the mailbox name. Mailboxes are
`<provider>:<identifier>`, and it is the *identifier* that later gains
bucket and event-type suffixes, so the first segment stays the provider.
The column is nullable and rows predating it still drain through, hence
the `unknown` fallback — matching what `record_mailbox_depth_metrics`
already does.

### Rebased onto #121606

That PR added two new `delivery` outcomes — `conflict` and `dropped_4xx`
— for payloads a cell permanently rejects. Both are tagged here too, so
every `delivery` emission carries `provider`; otherwise those two would
have been the only outcomes to vanish when a provider is selected, which
is the exact failure this PR exists to remove.

### Deliberately left untagged

Following the cardinality restraint in #121601 ("every tag value costs a
series per worker"):

- **`send_request` timer** — a timer is seven series, so this would be 7
× cells × providers, for a latency question `delivery_time_ms` already
answers.
- **`schedule_webhook_delivery.mailbox_count`** — aggregates across
every mailbox in a scheduler run, so there is no single provider to
attribute it to.

### Cost

`delivery` goes to outcome × provider, `failure` to reason × cell ×
provider. Provider values are bounded by the integration list — Datadog
currently sees 10 distinct values on the mailbox gauges.
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.

2 participants