Skip to content

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

Open
Christinarlong wants to merge 3 commits into
masterfrom
Christinarlong/webhook-debugging-tools
Open

impr(sentry apps): Add Duration, Resource ids, Request id to the dashboard#122930
Christinarlong wants to merge 3 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?

@@ -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)

@@ -361,6 +260,52 @@ def test_errors_only_filter(self) -> None:
assert response.status_code == 200
assert len(response.data) == 2

def test_request_id_subject_and_duration_on_success_and_error_rows(self) -> None:
"""request_id, subject, and duration are surfaced on both success and error rows."""

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.

Suggested change
"""request_id, subject, and duration are surfaced on both success and error rows."""

nit: this is just restating the line above it

) == ("456", "preprod_artifact")


def test_realistic_payload_fixtures_stay_within_buffer_limit() -> None:

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.

I might be misunderstanding but this seems to not be testing anything at all?

) == ("d1e2f3a4-5678-4b9c-8d0e-1f2a3b4c5d6e", "autofix_run")


def test_seer_run_id_zero_is_not_treated_as_missing() -> None:

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.

Curious when we'd expect this to happen?

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