66
77from sentry import options
88from sentry .constants import ObjectStatus
9+ from sentry .integrations .github .webhook_types import GITHUB_WEBHOOK_TYPE_HEADER , GithubWebhookType
910from sentry .integrations .models .integration import Integration
1011from sentry .integrations .models .organization_integration import OrganizationIntegration
1112from sentry .models .organizationmapping import OrganizationMapping
1617
1718# TODO: Double check that this includes all of the events you care about.
1819GITHUB_EVENTS_TO_FORWARD_OVERWATCH = {
19- "installation" ,
20- "installation_repositories" ,
21- "issue_comment" ,
22- "pull_request" ,
23- "pull_request_review_comment" ,
24- "pull_request_review" ,
20+ GithubWebhookType . INSTALLATION ,
21+ GithubWebhookType . INSTALLATION_REPOSITORIES ,
22+ GithubWebhookType . ISSUE_COMMENT ,
23+ GithubWebhookType . PULL_REQUEST ,
24+ GithubWebhookType . PULL_REQUEST_REVIEW_COMMENT ,
25+ GithubWebhookType . PULL_REQUEST_REVIEW ,
2526}
2627
2728
@@ -45,7 +46,7 @@ def __init__(self, integration: Integration):
4546 self .integration = integration
4647
4748 def should_forward_to_overwatch (self , headers : Mapping [str , str ]) -> bool :
48- return headers .get ("HTTP_X_GITHUB_EVENT" ) in GITHUB_EVENTS_TO_FORWARD_OVERWATCH
49+ return headers .get (GITHUB_WEBHOOK_TYPE_HEADER ) in GITHUB_EVENTS_TO_FORWARD_OVERWATCH
4950
5051 def _get_org_summaries_by_region_for_integration (
5152 self , integration : Integration
@@ -108,12 +109,8 @@ def forward_if_applicable(self, event: Mapping[str, Any], headers: Mapping[str,
108109 region_name = None
109110 try :
110111 enabled_regions = options .get ("overwatch.enabled-regions" )
111- logger .info (
112- "overwatch.debug.enabled_regions" , extra = {"enabled_regions" : enabled_regions }
113- )
114112 if not enabled_regions :
115113 # feature isn't enabled, no work to do
116- logger .info ("overwatch.debug.excluded.feature_not_enabled" , extra = {})
117114 return
118115
119116 orgs_by_region = self ._get_org_summaries_by_region_for_integration (
@@ -177,10 +174,6 @@ def forward_if_applicable(self, event: Mapping[str, Any], headers: Mapping[str,
177174 region = region_name ,
178175 app_id = app_id ,
179176 )
180- logger .info (
181- "overwatch.debug.webhook_detail.created" ,
182- extra = {"region_name" : region_name , "app_id" : app_id },
183- )
184177
185178 publisher = OverwatchWebhookPublisher (
186179 integration_provider = self .integration .provider ,
@@ -193,9 +186,6 @@ def forward_if_applicable(self, event: Mapping[str, Any], headers: Mapping[str,
193186 sample_rate = 1.0 ,
194187 tags = {"forward_region" : region_name },
195188 )
196- logger .info (
197- "overwatch.debug.metrics_incr.success" , extra = {"region_name" : region_name }
198- )
199189 except Exception :
200190 metrics .incr (
201191 "overwatch.forward-webhooks.forward-error" ,
0 commit comments