Skip to content

feat(code_review): control: include github_event & action info#109995

Merged
armenzg merged 2 commits intomasterfrom
include_provider_in_metric/code_review
Mar 10, 2026
Merged

feat(code_review): control: include github_event & action info#109995
armenzg merged 2 commits intomasterfrom
include_provider_in_metric/code_review

Conversation

@armenzg
Copy link
Member

@armenzg armenzg commented Mar 5, 2026

We want to slice the data with more granularity.

@armenzg armenzg self-assigned this Mar 5, 2026
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2026

def _get_github_delivery_time_tags(payload: WebhookPayload) -> dict[str, str]:
"""Extract GitHub event type and action from payload for delivery_time_ms metric tags."""
if payload.provider != "github":
Copy link
Member Author

Choose a reason for hiding this comment

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

At the moment we only care about GitHub for code reviews.

def _record_delivery_time_metrics(payload: WebhookPayload) -> None:
"""Record delivery time metrics for a successfully delivered webhook payload."""
exclude_mailboxes = set(
options.get("hybridcloud.deliver_webhooks.delivery_time_exclude_mailboxes") or ()
Copy link
Member Author

Choose a reason for hiding this comment

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

Orthogonal: We don't need this flag anymore.

flags=FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"hybridcloud.deliver_webhooks.delivery_time_exclude_mailboxes",
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed anymore.

mailbox_name="github:123",
mailbox_name="stripe:123",
region_name="us",
provider="stripe",
Copy link
Member Author

Choose a reason for hiding this comment

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

Since the provider is stripe we will not have the extra two tags.

@armenzg armenzg marked this pull request as ready for review March 5, 2026 21:53
@armenzg armenzg requested a review from a team as a code owner March 5, 2026 21:53
Copy link
Contributor

@cursor cursor bot left a comment

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.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Test doesn't enable feature flag, never exercises provider filtering
    • Added missing @override_options decorator to enable the feature flag so the test actually exercises the provider filtering logic.

Create PR

Or push these changes by commenting:

@cursor push 3e8628efd8
Preview (3e8628efd8)
diff --git a/tests/sentry/hybridcloud/tasks/test_deliver_webhooks.py b/tests/sentry/hybridcloud/tasks/test_deliver_webhooks.py
--- a/tests/sentry/hybridcloud/tasks/test_deliver_webhooks.py
+++ b/tests/sentry/hybridcloud/tasks/test_deliver_webhooks.py
@@ -1106,6 +1106,7 @@
 
     @responses.activate
     @override_regions(region_config)
+    @override_options({"hybridcloud.deliver_webhooks.delivery_time_include_github_tags": True})
     @patch("sentry.hybridcloud.tasks.deliver_webhooks.metrics")
     def test_delivery_time_metrics_non_github_no_github_tags(self, mock_metrics: MagicMock) -> None:
         responses.add(

tags = delivery_time_ms_calls[0][1].get("tags", {})
assert tags.get("region_sent_to") == "us"
assert "github_event_type" not in tags
assert "github_action" not in tags
Copy link
Contributor

Choose a reason for hiding this comment

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

Test doesn't enable feature flag, never exercises provider filtering

Low Severity

test_delivery_time_metrics_non_github_no_github_tags is missing the @override_options({"hybridcloud.deliver_webhooks.delivery_time_include_github_tags": True}) decorator. Since the option defaults to False, _get_github_delivery_time_tags is never called, and the assertions that github_event_type and github_action are absent pass trivially. The test doesn't actually validate that non-GitHub providers are filtered out by the provider check — a bug in that check would go undetected.

Fix in Cursor Fix in Web

Copy link
Contributor

@tnt-sentry tnt-sentry left a comment

Choose a reason for hiding this comment

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

🚀

@armenzg armenzg merged commit c97560c into master Mar 10, 2026
58 checks passed
@armenzg armenzg deleted the include_provider_in_metric/code_review branch March 10, 2026 12:37
JoshuaKGoldberg pushed a commit that referenced this pull request Mar 10, 2026
We want to slice the data with more granularity.
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.

3 participants