Repository navigation
perf(control): Drop unconsumed check_suite webhook actions at the parser - #121434
Merged
Merged
Conversation
check_suite is the highest-volume GitHub webhook we deliver (~13.6M/day, more than check_run), but its only consumers — pr_metrics' handle_check_suite and the SCM stream's pr_iteration listener — both return immediately unless the action is "completed". Every "requested" and "rerequested" delivery was still stored as a WebhookPayload, sent cross-silo, signature-verified, parsed, dispatched, and republished to Kafka before being discarded. check_run has had this filter since #119829; generalize it into CELL_PROCESSED_ACTIONS so an event type declares which of its actions a cell actually consumes, and apply it to check_suite as well. Also add github.webhook.forwarded_event, the counter for what survives the filter, to sit opposite the existing drop counter — until now only drops were measured, so the forwarded share of each event type was invisible. On completed check events it carries has_own_repo_pr, which reports whether the payload references a pull request based in this repo. Checks that reference none are a guaranteed no-op in the cell, so that tag sizes a further drop we cannot justify without the number.
vaind
requested review from
a team,
alexsohn1126,
giovanni-guidini and
joseph-sentry
August 6, 2026 16:13
alexsohn1126
approved these changes
Aug 6, 2026
markstory
reviewed
Aug 7, 2026
The local _as_mapping helper reimplemented what sentry.utils.safe.get_path already does for untrusted nested data, and the base.repo.id lookup needed three nested calls to stay safe against a malformed payload.
…d-check-suite-webhooks
vaind
enabled auto-merge (squash)
August 10, 2026 09:06
vaind
added a commit
that referenced
this pull request
Aug 10, 2026
## 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.
vaind
added a commit
that referenced
this pull request
Aug 11, 2026
Trim the shared-module and resolver docstrings to the reasoning that is not already evident from the code, and drop the restatement in _prs_from_check_payload now that the rule has one home. Also fixes an inverted clause inherited from #121434: the predicate drops on False, so the hazard is a False for a payload a consumer would act on, not a True for one it would ignore.
vaind
added a commit
that referenced
this pull request
Aug 11, 2026
…est in their own repo (#121719) ## Problem `check_run.completed` and `check_suite.completed` are the two largest remaining lines at the control parser — **11.8M and 9.9M/day**, the former at ~110ms average, roughly 370 CPU-hours/day in the cell handler alone — and about a third of each does no work when it lands. GitHub lists a PR on a check whenever the two share a head sha, which includes 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 carrying none of those resolves zero PRs and writes nothing. Today every one of them is still 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. Both sides of that comparison are in the payload, so control can make the call without the cell's database. The predicate is not an approximation of the cell's filter — it is the same comparison: `GitHubWebhook.__call__` looks the `Repository` row up by `external_id=str(event["repository"]["id"])`, which is exactly what the parser compares `base.repo.id` against. Measured over a full 24h window: | event | total/day | no own-repo PR | share | | --- | --- | --- | --- | | `check_run.completed` | 11.83M | 3.75M | 31.7% | | `check_suite.completed` | 9.87M | 3.73M | 37.8% | **~7.5M requests/day** combined (~8.5M rows after the 1.13× cell fan-out), against a peak-hour backlog surplus of 110–140K rows/h. ## Changes **The drop.** `ActionFilter` gains `own_repo_pr_actions` — the actions where *every* cell-side consumer resolves PRs through the payload's own repo. `references_own_repo_pull_request` was already implemented in #121434 to tag the forwarded counter; it now decides. For `check_run.completed` all three processors were re-checked: `handle_preprod_check_run_event` returns unless `requested_action`, code review's `handle_check_run_event` returns unless `rerequested`, and only `pr_metrics_handle_check_run` reads `pull_requests`. The SCM stream's `listen_for_check_run` is still a no-op stub. **`check_suite.completed` has a second consumer** — Seer's `pr_iteration_from_check_suite_listener`, via the SCM stream — so the predicate rests on two filters there rather than one. Both resolve through the shared `is_own_repo_pull_request` as of #121724 (merged), which also fixed a foreign-base entry shadowing the own-repo one. So `check_suite` takes exactly `check_run`'s rule, with no carve-out, and the drop is a subset of both consumers' no-op sets. **The kill switch.** Unlike the existing parser drops, this one keys off payload shape rather than a header, so it ships behind `hybridcloud.webhookpayload.github_drop_checks_without_own_repo_pr`, **default off**. As merged this is a strict no-op. One option covers both event types. **The signal that makes the switch usable.** A switch is only worth having if a wrong predicate is detectable, and it was not: `_write_activity_row` is a bare insert, so silently losing these events would move no counter anywhere and GitHub — already 202'd — never redelivers. `pr_metrics.check.activity_recorded` closes that gap. It must stay **flat** when the option is enabled; any dip is the predicate being wrong, visible within the hour instead of never. `drop_unprocessed_event` also gains a `reason` tag (`unprocessed_event_type` / `unconsumed_action` / `no_own_repo_pr`) so the new drop is separable from the two existing ones. The metric is in Datadog exclude-tags mode, so the tag indexes with no dashboard-side config. ## Rollout Enable the option, then watch two things together, per event type: ``` sum:sentry.github.webhook.drop_unprocessed_event{reason:no_own_repo_pr} by {event_type}.as_count() sum:sentry.pr_metrics.check.activity_recorded{*} by {github_event}.as_count() ``` The first should climb toward ~3.75M/day for `check_run` and ~3.73M/day for `check_suite` while the second does not move. `forwarded_event{action:completed,has_own_repo_pr:false}` should fall to zero for both over the same window — the tag and the drop now use the same predicate, so there is no expected residual on either event type. The option is a rollout control, not a permanent feature — it should be removed once a week of flat activity volume confirms the predicate. ## Risk Most of the reclaimed volume is not the subtle case. The cell's `pr_metrics.check.foreign_pull_request` counter — one increment per entry skipped for a non-matching `base.repo` — runs at 759K/day across *both* check event types, counting entries rather than payloads, and including payloads that also carried an own-repo entry and were processed normally. So **at least ~79% of the drop is the empty `pull_requests: []` case**: CI on a commit with no PR, where "the cell does nothing" is `for ref in ()`, not an inference about repo identity. One second-order effect, the same one #121434 called out for `check_suite`: `GitHubWebhook.__call__` auto-creates missing `Repository` rows and calls `update_repo_data()` for any event carrying a `repository` key, independent of the processors, and dropped deliveries no longer trigger that. Safe for the same reason — `push`, `pull_request` and `issue_comment` all still flow through that path. Minor observability change: code review's `record_webhook_received` / `record_webhook_filtered(UNSUPPORTED_ACTION)` counters stop firing for dropped `check_run.completed`. No behavior attached. Fixes [CW-1838](https://linear.app/getsentry/issue/CW-1838)
This branch was successfully deployed
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.
Problem
check_suiteis the single highest-volume GitHub webhook we deliver to cells — ~13.6M/day, ahead ofcheck_runat 12.1M/day and roughly 36% of allWebhookPayloadrows written across every provider (37.7M/day). Unlikecheck_run, none of its actions were filtered in control.Only
completedhas a consumer. Both consumer paths agree on this:pr_metrics.handle_check_suite, the sole entry inCheckSuiteWebhook.WEBHOOK_EVENT_PROCESSORS, returns unlessaction == "completed"pr_iteration_from_check_suite_listeneron the SCM event stream does the sameSo every
requestedandrerequesteddelivery was stored as aWebhookPayload, 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_runhas had one since #119829. This replaces the two loosecheck_runconstants withCELL_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_suiteis added withconsumed={"completed"}.Add the missing half of the funnel.
github.webhook.forwarded_eventcounts what survives the filter, opposite the existinggithub.webhook.drop_unprocessed_event. Until now only drops were measured, so the forwarded share of each event type was invisible in Datadog.On
completedcheck events the counter carrieshas_own_repo_pr.check_run/check_suitepayloads list PRs that merely share a head sha, including PRs based in other repositories; the cell's_prs_from_check_payloadresolves only entries whosebase.repois 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.completedis 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_suitedrop, 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 missingRepositoryrows and callsupdate_repo_data()for any event carrying arepositorykey, independent of the processors. Droppedcheck_suitedeliveries no longer trigger that. This is safe —push,pull_request,check_run.completedandissue_commentall 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.completeddeliveries 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_suitefilter, 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:The
falseshare is what the drop would reclaim.check_suite.completedis measured by the same tag and would follow the same predicate.Before narrowing further, re-check both consumer paths:
WEBHOOK_EVENT_PROCESSORSon the endpoint, and thesentry.scm.streamlisteners.check_runhas only a stub listener on the stream today, but that can change.Fixes CW-1838