feat(observability): Add baseline tags to RPC sourced sentry errors#7845
feat(observability): Add baseline tags to RPC sourced sentry errors#7845
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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.
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) |
There was a problem hiding this comment.
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.



Make it easier for us to debug request errors