Skip to content

feat(control): Drop unconsumed check_run webhook actions at the parser - #119829

Merged
vaind merged 1 commit into
masterfrom
ivan/drop-unconsumed-check-run-actions
Jul 16, 2026
Merged

vaind merged 1 commit into
masterfrom
ivan/drop-unconsumed-check-run-actions

Conversation

@vaind

@vaind vaind commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Problem

The GitHub App now subscribes to check_run events, which immediately became the highest-volume GitHub event type forwarded from the control silo to region cells — contributing to webhook delivery backlogs. Roughly half of that volume is action=created, which no cell-side processor consumes:

Consumer Actions consumed
pr_metrics (sentry.pr_metrics.webhooks.handle_check_run) completed only
Seer code review (sentry.seer.code_review.webhooks.check_run) rerequested only
preprod (sentry.preprod.vcs.webhooks.github_check_run) requested_action only

Also verified: the SCM event stream's only registered check_run listener is a no-op placeholder, and the generic GitHubWebhook base does nothing action-specific. GHE uses the same processors and its request parser inherits get_response, so the drop applies there too (desired).

Approach

Drop check_run events whose action has no consumer at the control parser — right beside the existing unprocessed-event-type drop, so it only runs after integration/cell resolution. Dropped events get a 202 and a github.webhook.drop_unprocessed_event metric with an action tag. The tag is only emitted verbatim for known GitHub check_run actions (otherwise unknown): the body is not signature-verified until it reaches the cell, so raw values must not become metric tags.

CELL_PROCESSED_CHECK_RUN_ACTIONS lives next to the event-type allowlist in webhook_types.py with the consumer→action mapping documented — a new consumer must add its action there to receive those events.

Testing

  • 7 new parser tests: created → dropped (202, no WebhookPayload rows, metric); completed/rerequested/requested_action → forwarded unchanged; bogus/missing/non-string actions → dropped with bounded unknown tag.
  • Full parser test modules pass (49/49), prek/mypy clean.

The GitHub App now subscribes to check_run events, which immediately
became the highest-volume GitHub event type forwarded from control to
region cells. Only three actions have a cell-side consumer (completed
-> pr_metrics, rerequested -> Seer code review, requested_action ->
preprod); created, roughly half of all check_run deliveries, has no
consumer at all.

Drop unconsumed actions at the control parser before a WebhookPayload
is created, mirroring the existing unprocessed-event-type drop. The
action metric tag is only emitted verbatim for known GitHub check_run
actions because the request body is not signature-verified until it
reaches the cell.
@vaind
vaind requested review from a team as code owners July 16, 2026 16:35
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 16, 2026
@vaind
vaind requested a review from a team July 16, 2026 16:35
@vaind
vaind merged commit 2a83227 into master Jul 16, 2026
67 checks passed
@vaind
vaind deleted the ivan/drop-unconsumed-check-run-actions branch July 16, 2026 18:32
hobzcalvin pushed a commit that referenced this pull request Jul 16, 2026
#119829)

## Problem

The GitHub App now subscribes to `check_run` events, which immediately
became the highest-volume GitHub event type forwarded from the control
silo to region cells — contributing to webhook delivery backlogs.
Roughly half of that volume is `action=created`, which **no cell-side
processor consumes**:

| Consumer | Actions consumed |
|---|---|
| pr_metrics (`sentry.pr_metrics.webhooks.handle_check_run`) |
`completed` only |
| Seer code review (`sentry.seer.code_review.webhooks.check_run`) |
`rerequested` only |
| preprod (`sentry.preprod.vcs.webhooks.github_check_run`) |
`requested_action` only |

Also verified: the SCM event stream's only registered `check_run`
listener is a no-op placeholder, and the generic `GitHubWebhook` base
does nothing action-specific. GHE uses the same processors and its
request parser inherits `get_response`, so the drop applies there too
(desired).

## Approach

Drop `check_run` events whose action has no consumer at the control
parser — right beside the existing unprocessed-event-type drop, so it
only runs after integration/cell resolution. Dropped events get a 202
and a `github.webhook.drop_unprocessed_event` metric with an `action`
tag. The tag is only emitted verbatim for known GitHub check_run actions
(otherwise `unknown`): the body is not signature-verified until it
reaches the cell, so raw values must not become metric tags.

`CELL_PROCESSED_CHECK_RUN_ACTIONS` lives next to the event-type
allowlist in `webhook_types.py` with the consumer→action mapping
documented — a new consumer must add its action there to receive those
events.

## Testing

- 7 new parser tests: `created` → dropped (202, no WebhookPayload rows,
metric); `completed`/`rerequested`/`requested_action` → forwarded
unchanged; bogus/missing/non-string actions → dropped with bounded
`unknown` tag.
- Full parser test modules pass (49/49), prek/mypy clean.
vaind added a commit that referenced this pull request Aug 10, 2026
…ser (#121434)

## Problem

`check_suite` is the single highest-volume GitHub webhook we deliver to
cells — **\~13.6M/day**, ahead of `check_run` at 12.1M/day and roughly
36% of all `WebhookPayload` rows written across every provider
(37.7M/day). Unlike `check_run`, none of its actions were filtered in
control.

Only `completed` has a consumer. Both consumer paths agree on this:

* `pr_metrics.handle_check_suite`, the sole entry in
`CheckSuiteWebhook.WEBHOOK_EVENT_PROCESSORS`, returns unless `action ==
"completed"`
* `pr_iteration_from_check_suite_listener` on the SCM event stream does
the same

So every `requested` and `rerequested` delivery was stored as a
`WebhookPayload`, POSTed cross-silo, HMAC-verified, JSON-parsed,
dispatched through the per-org handler loop, and republished to Kafka
with its full body — then dropped on the floor.

## Changes

**Generalize the action filter.** `check_run` has had one since
#119829. This replaces the two loose `check_run`
constants with `CELL_PROCESSED_ACTIONS`, where an event type declares
which of its actions a cell consumes (`consumed`) and which actions
GitHub documents for it (`known`, which bounds metric tag cardinality —
the body is not signature-verified in control). `check_suite` is added
with `consumed={"completed"}`.

**Add the missing half of the funnel.** `github.webhook.forwarded_event`
counts what survives the filter, opposite the existing
`github.webhook.drop_unprocessed_event`. Until now only drops were
measured, so the forwarded share of each event type was invisible in
Datadog.

On `completed` check events the counter carries `has_own_repo_pr`.
`check_run`/`check_suite` payloads list PRs that merely share a head
sha, including PRs based in *other* repositories; the cell's
`_prs_from_check_payload` resolves only entries whose `base.repo` is
this webhook's repo, so a payload matching none of them is a guaranteed
no-op there. Both sides of that comparison are already in the payload,
which makes the share measurable from control. That number sizes a
further drop — `check_run.completed` is the largest remaining line at
12.1M/day and 110ms avg — that shouldn't be shipped on a guess.

## Behavior

No functional change beyond the `check_suite` drop, and that drop is a
strict no-op: it removes deliveries every consumer already discarded.

One second-order effect worth naming. `GitHubWebhook.__call__`
auto-creates missing `Repository` rows and calls `update_repo_data()`
for any event carrying a `repository` key, independent of the
processors. Dropped `check_suite` deliveries no longer trigger that.
This is safe — `push`, `pull_request`, `check_run.completed` and
`issue_comment` all still flow through the same path, and a push
necessarily precedes any check suite — but it is the non-obvious part of
the change.

## Follow-up

Dropping `check_run.completed` deliveries that reference no pull request
based in this repo. It is the largest remaining line — 12.1M/day at
\~110ms average, roughly 370 CPU-hours/day in the cell handler alone —
and the payload-only predicate is already implemented here as
`_references_own_repo_pull_request`, currently used only to tag the
counter.

Deliberately not in this PR. Unlike the `check_suite` filter, this one
keys off payload shape rather than a header, so it needs its own review
and an options kill switch — a wrong predicate loses events silently,
and the existing drops have no escape hatch. It also needs a number that
does not exist yet. Once this counter has run for a day:

```
sum:sentry.github.webhook.forwarded_event{event_type:check_run,action:completed} by {has_own_repo_pr}
```

The `false` share is what the drop would reclaim.
`check_suite.completed` is measured by the same tag and would follow the
same predicate.

Before narrowing further, re-check both consumer paths:
`WEBHOOK_EVENT_PROCESSORS` on the endpoint, and the `sentry.scm.stream`
listeners. `check_run` has only a stub listener on the stream today, but
that can change.

Fixes [CW-1838](https://linear.app/getsentry/issue/CW-1838)
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