Skip to content

feat(observability): Add baseline tags to RPC sourced sentry errors#7845

Merged
volokluev merged 8 commits intomasterfrom
volo/error_report
Mar 27, 2026
Merged

feat(observability): Add baseline tags to RPC sourced sentry errors#7845
volokluev merged 8 commits intomasterfrom
volo/error_report

Conversation

@volokluev
Copy link
Copy Markdown
Member

Make it easier for us to debug request errors

volokluev and others added 7 commits March 25, 2026 11:24
Tag all SnQL API errors with referrer, tenant_ids, and source:snql_api
to improve error tracking and debugging. This enables filtering and
grouping errors by organization, project, and referrer in Sentry.

The tags are set early in the request lifecycle so any error during
parsing, validation, or query execution will include this context.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Wrap _set_snql_api_error_tags in try-except to ensure that any failure
in setting Sentry tags does not crash the API request. Failures are
logged as warnings for debugging.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@volokluev volokluev requested review from a team as code owners March 27, 2026 17:09
Copy link
Copy Markdown

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

Fix All in Cursor

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

  • ✅ Fixed: Tags set before request_id is generated
    • Moved _set_rpc_error_tags call to after __before_execute to ensure request_id is generated before setting Sentry tags.

Create PR

Or push these changes by commenting:

@cursor push e0eedf3974
Preview (e0eedf3974)
diff --git a/snuba/web/rpc/__init__.py b/snuba/web/rpc/__init__.py
--- a/snuba/web/rpc/__init__.py
+++ b/snuba/web/rpc/__init__.py
@@ -212,9 +212,9 @@
             in_msg=in_msg,
             query_id=uuid.uuid4().hex,
         )
-        _set_rpc_error_tags(in_msg)
 
         self.__before_execute(in_msg)
+        _set_rpc_error_tags(in_msg)
         error: Exception | None = None
         meta = getattr(in_msg, "meta", RequestMeta())
         try:

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

in_msg=in_msg,
query_id=uuid.uuid4().hex,
)
_set_rpc_error_tags(in_msg)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tags set before request_id is generated

Medium Severity

_set_rpc_error_tags(in_msg) is called at line 215 before self.__before_execute(in_msg) at line 217. The __before_execute method generates request_id when it's not already present on the message. Since _set_rpc_error_tags checks meta.request_id for truthiness and skips the tag if it's empty, the request_id Sentry tag will be missing whenever the client doesn't provide one — which is likely the common case.

Additional Locations (1)
Fix in Cursor Fix in Web

@volokluev volokluev merged commit d5ef212 into master Mar 27, 2026
46 of 47 checks passed
@volokluev volokluev deleted the volo/error_report branch March 27, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants