Skip to content

impr(sentry apps): Add Duration, Resource ids, Request id to the dashboard - #122930

Merged
Christinarlong merged 4 commits into
masterfrom
Christinarlong/webhook-debugging-tools
Aug 31, 2026
Merged

impr(sentry apps): Add Duration, Resource ids, Request id to the dashboard#122930
Christinarlong merged 4 commits into
masterfrom
Christinarlong/webhook-debugging-tools

Conversation

@Christinarlong

@Christinarlong Christinarlong commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Adds 4 new fields to the request buffer

    request_id: NotRequired[str | None]  # Maps to requestId header on webhook
    subject_id: NotRequired[str | None]  # ID for the resource denoted in subjectType
    subject_type: NotRequired[str | None]  # Resource type (e.g. Group, Event, Seer Run)
    duration_ms: NotRequired[int | None]  # Time taken to send the request

For the subject/resource fields, there's a mapping we do that first checks if the specific event_type (issue.created, seer.autofix_run_started etc.) has a resource override else we have default resources(e.g Event, Group etc.) for each of the webhook resources. Currently the mapping from webhook resource -> subject is 1:1 but I think that makes sense for most cases since webhooks are generally some model being serialized.

This PR also breaks out ConnectionError to be its own handling (kinda), mainly jsut add a new fake status code so we can tell in the UI

@Christinarlong
Christinarlong requested review from a team as code owners August 27, 2026 20:49
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 27, 2026
Comment thread src/sentry/utils/sentry_apps/webhooks.py
Comment thread src/sentry/utils/sentry_apps/webhooks.py
Comment thread src/sentry/utils/sentry_apps/webhooks.py
Comment thread src/sentry/utils/sentry_apps/webhooks.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit dbda0ff. Configure here.

Comment thread src/sentry/utils/sentry_apps/webhooks.py
Comment thread src/sentry/utils/sentry_apps/webhooks.py
Comment thread src/sentry/utils/sentry_apps/webhooks.py Outdated
SentryAppResourceType.ISSUE: SubjectSpec("group", [("issue", "id")]),
SentryAppResourceType.ACTIVITY_ALERT: SubjectSpec("group", [("issue", "id")]),
SentryAppResourceType.COMMENT: SubjectSpec("comment", [("comment_id",)]),
# TODO: AlertRule is a legacy model and should be migrated to Detector when we phase out the legacy payload

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we just not support this to spare ourselves cleanup work later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The current discrepancy is that the the webhooks still use a payload body that references the legacy models and doesn't have any identifiers to the new models 😭 . I think we should have a top level resource/subject identifier for all the resources so I think we should start with this.

The real shim/fix would be updating the metric alert payload to have detector or smthn and just using that here.

@@ -386,6 +416,10 @@ def send_and_save_webhook_request(
if (p_id := response.headers.get("Sentry-Hook-Project")) and p_id.isdigit()
else None
)
elapsed = getattr(response, "elapsed", None)
duration_ms = (

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could also potentially record the duration here and above on connection errors as the difference between just before _send_webhook_request and now - not sure if that's meaningful but it would mean that we always have a duration on all requests (after 30d)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would prefer we have a p. certain source of truth of the response object for the duration (i.e how long did the req itself take versus anything surrounding since that's what the timeout is working against. Other custom timers Imo would get confusing and I think for connection errors idt duration would be too useful since it's not a latency type error.

Comment thread tests/sentry/sentry_apps/api/endpoints/test_sentry_app_webhook_requests.py Outdated
Comment thread tests/sentry/sentry_apps/utils/test_webhook_subjects.py Outdated
Comment thread tests/sentry/sentry_apps/utils/test_webhook_subjects.py Outdated
@Christinarlong
Christinarlong merged commit 78c52d3 into master Aug 31, 2026
68 checks passed
@Christinarlong
Christinarlong deleted the Christinarlong/webhook-debugging-tools branch August 31, 2026 23:38
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