Skip to content

feat(pr-metrics): Add merge_commit_id to the PR close/merge event#117318

Merged
Zylphrex merged 1 commit into
masterfrom
feat/pr-metrics-merge-commit-id
Jun 10, 2026
Merged

feat(pr-metrics): Add merge_commit_id to the PR close/merge event#117318
Zylphrex merged 1 commit into
masterfrom
feat/pr-metrics-merge-commit-id

Conversation

@Zylphrex

Copy link
Copy Markdown
Member

Adds merge_commit_id to the PrCloseMetricsEvent analytics row emitted when a tracked PR is closed or merged.

The row previously carried only the merge commit SHA, which can't be joined to Sentry's own commit/release data downstream (BigQuery). We now resolve the merge commit's Sentry Commit.id from merge_commit_sha via the (repository_id, key) unique key and emit it on the event, so consumers can connect a merged PR to the commit Sentry tracks.

The field is nullable: null when the PR wasn't merged (merge_commit_sha is None) or when Sentry never recorded the landed commit — the pr_metrics module never creates Commit rows, so a match isn't guaranteed and we don't fail loud.

We resolve the merge commit rather than the head commit because the merge commit is what GitHub lands on the base branch (the squashed commit for squash-and-merge, the merge commit for a regular merge, the last rebased commit for a rebase merge). That's the commit Sentry's release tracking is most likely to have recorded; the head SHA points at the pre-merge branch tip, which is frequently squashed away and untracked.

The lookup is an equality match on (repository_id, key), fully covered by the unique composite index that unique_together = (("repository_id", "key"),) creates on sentry_commit — a single unique index lookup, no new index needed.

The PR-metrics close/merge row carried only the merge commit SHA, which
can't be joined to Sentry's own commit/release data downstream. Resolve
the merge commit's Sentry Commit.id from merge_commit_sha via the
(repository_id, key) unique key and emit it on the event.

The field is nullable: null when the PR wasn't merged or Sentry never
recorded the landed commit (the pr_metrics module never creates Commit
rows). The merge commit is chosen over the head commit because it's the
commit GitHub lands on the base branch (the squashed commit for
squash-and-merge), so it's the one release tracking is most likely to
have recorded.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 10, 2026
@Zylphrex Zylphrex marked this pull request as ready for review June 10, 2026 18:56
@Zylphrex Zylphrex requested review from a team as code owners June 10, 2026 18:56
@Zylphrex Zylphrex merged commit bc96e87 into master Jun 10, 2026
62 of 67 checks passed
@Zylphrex Zylphrex deleted the feat/pr-metrics-merge-commit-id branch June 10, 2026 19:11
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