Skip to content

feat(hybridcloud): Tag webhook delivery metrics by provider - #121609

Merged
vaind merged 2 commits into
masterfrom
ref/webhook-provider-metric-tag
Aug 10, 2026
Merged

vaind merged 2 commits into
masterfrom
ref/webhook-provider-metric-tag

Conversation

@vaind

@vaind vaind commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Why

The 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.

@vaind
vaind requested a review from a team as a code owner August 10, 2026 12:14
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 10, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c962807. Configure here.

@vaind
vaind requested a review from joseph-sentry August 10, 2026 13:38
vaind added a commit that referenced this pull request Aug 10, 2026
…cord

`drain_mailbox` loops over records but keeps a separate reference to the mailbox
head, and the retry counter read the head. Every other delivery outcome reads the
record it describes — `ok` and `attempts_exceed` via `deliver_message`, and the
whole parallel path via `payload_record` — so the same webhook could be attributed
to two providers depending on how it ended.

Only reachable through the nullable provider column, since a mailbox name pins the
provider for every row in it, and production currently has no null-provider rows.
Fixing it anyway: the parallel path already reads the record, and the cost is one
word.

Reported by Cursor Bugbot on #121609.
vaind added 2 commits August 10, 2026 19:06
The 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. Selecting a provider therefore does not
filter those widgets, it blanks them, which reads as "no traffic" rather than
"this metric cannot answer that question".

Tagging them 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.

Provider comes from the payload column where a row is loaded. Two paths have no
row — the push trigger, and the DoesNotExist race — so they read the first
segment of the mailbox name instead; bucket and event-type suffixes attach to
the identifier, so that segment stays the provider. The column is nullable and
rows predating it still drain through, hence the `unknown` fallback, matching
`record_mailbox_depth_metrics`.

Left untagged deliberately: the `send_request` timer, which would multiply seven
series per cell for a latency question `delivery_time_ms` already answers, and
`schedule_webhook_delivery.mailbox_count`, which aggregates across providers.
…cord

`drain_mailbox` loops over records but keeps a separate reference to the mailbox
head, and the retry counter read the head. Every other delivery outcome reads the
record it describes — `ok` and `attempts_exceed` via `deliver_message`, and the
whole parallel path via `payload_record` — so the same webhook could be attributed
to two providers depending on how it ended.

Only reachable through the nullable provider column, since a mailbox name pins the
provider for every row in it, and production currently has no null-provider rows.
Fixing it anyway: the parallel path already reads the record, and the cost is one
word.

Reported by Cursor Bugbot on #121609.
@vaind
vaind force-pushed the ref/webhook-provider-metric-tag branch from 43cfc61 to 03ab175 Compare August 10, 2026 17:07
@vaind
vaind enabled auto-merge (squash) August 10, 2026 17:09
@vaind
vaind merged commit cff3fad into master Aug 10, 2026
57 of 58 checks passed
@vaind
vaind deleted the ref/webhook-provider-metric-tag branch August 10, 2026 17:17
vaind added a commit that referenced this pull request Aug 10, 2026
## Problem

`hybridcloud.deliver_webhooks.delivery_time_ms` is tagged with
`region_sent_to` and, for GitHub, `github_event_and_action` — but not
`provider`. A latency regression confined to one integration is
invisible until it is large enough to move the aggregate, and the
`$provider` selector on the Hybrid Cloud Webhook Forwarding dashboard
cannot reach the latency charts at all.

#121609 added a `provider` tag to every `delivery`, `failure`, `saved`
and `push_trigger.*` emission. `delivery_time_ms` was left out because
it is emitted from a different helper; this closes that gap.

## Change

`_record_delivery_time_metrics` now includes `provider` via the existing
`_provider_tag` helper, so payloads predating the nullable `provider`
column report `unknown` rather than dropping the tag.

The three existing `DeliveryTimeMetricsTest` cases already cover the
branches that matter, so they gained assertions instead of new tests: a
payload with no provider (`unknown`), a GitHub payload (`github`), and a
non-GitHub payload (`stripe`).

## No Datadog config needed

The metrics in #121609 sit behind an allowlist tag configuration that
has to be widened before `provider` becomes queryable.
`delivery_time_ms` configures tags by *exclusion* — only infra tags are
stripped — so `provider` is queryable as soon as it is emitted.
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