feat(pr-metrics): Add merge_commit_id to the PR close/merge event#117318
Merged
Conversation
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>
Mihir-Mavalankar
approved these changes
Jun 10, 2026
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.
Adds
merge_commit_idto thePrCloseMetricsEventanalytics 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.idfrommerge_commit_shavia 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:
nullwhen the PR wasn't merged (merge_commit_shaisNone) or when Sentry never recorded the landed commit — the pr_metrics module never createsCommitrows, 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 thatunique_together = (("repository_id", "key"),)creates onsentry_commit— a single unique index lookup, no new index needed.