Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(integrations): More diagnostic logging for inconsistent sentry apps #28578

Merged
merged 1 commit into from
Sep 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/sentry/tasks/sentry_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ def _process_resource_change(action, sender, instance_id, retryer=None, *args, *
event = f"{name}.{action}"

if event not in VALID_EVENTS:
org_id = Project.objects.get_from_cache(id=instance.project_id).organization_id
org = Organization.objects.get_from_cache(id=org_id)
if features.has("organizations:sentry-app-debugging", org):
logger.info(
"_process_resource_change.invalid_event.debug",
extra={
"event_type": event,
"organization_id": org_id,
"project_id": instance.project_id,
"valid_events": VALID_EVENTS,
},
)
return

org = None
Expand Down Expand Up @@ -287,9 +299,22 @@ def send_webhooks(installation, event, **kwargs):
organization_id=installation.organization_id, actor_id=installation.id
)
except ServiceHook.DoesNotExist:
logger.info(
"send_webhooks.missing_servicehook",
extra={"installation_id": installation.id, "event": event},
)
return

if event not in servicehook.events:
organization = Organization.objects.get_from_cache(id=installation.organization_id)
if features.has("organizations:sentry-app-debugging", organization):
logger.info(
"send_webhooks.dropped_event.debug",
extra={
"event_type": event,
"organization_id": installation.organization_id,
},
)
return

# The service hook applies to all projects if there are no
Expand Down Expand Up @@ -391,6 +416,19 @@ def send_and_save_webhook_request(sentry_app, app_platform_event, url=None):

else:
track_response_code(resp.status_code, slug, event)
organization = Organization.objects.get_from_cache(id=org_id)
if features.has("organizations:sentry-app-debugging", organization):
project_id = app_platform_event.data["error"].get("project")
logger.info(
"send_and_save_webhook_request.error",
extra={
"event_type": event,
"organization_id": org_id,
"integration_slug": sentry_app.slug,
"status": resp.status_code,
"project_id": project_id,
},
)
buffer.add_request(
response_code=resp.status_code,
org_id=org_id,
Expand Down