Skip to content

Commit 24acf06

Browse files
cvxluoandrewshie-sentry
authored andcommitted
fix(access-logs): capture more info in access log trace (#97585)
We need a bit more info to debug missing `organization_id`s (see [sentry issue](https://sentry.sentry.io/issues/6803717682/?project=1&query=is%3Aunresolved&referrer=issue-stream), [ticket](https://linear.app/getsentry/issue/ID-805/fix-missing-organization-id-in-api-access-logs)). From previous work, we suspect org id might be on either `_request` or `request_auth`, so logging those to see if we can find a pattern. See previous PR adding this: #97183
1 parent 7e5cd9b commit 24acf06

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/sentry/middleware/access_log.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,13 @@ def _create_api_access_log(
132132
metrics.incr("middleware.access_log.created")
133133

134134
if in_random_rollout("issues.log-access-logs") and not org_id:
135-
sentry_sdk.capture_message("Acesss log created without org_id", level="debug")
135+
with sentry_sdk.isolation_scope() as scope:
136+
scope.set_extra("request_auth", request_auth)
137+
scope.set_extra("request._request", request._request)
138+
sentry_sdk.capture_message(
139+
"Acesss log created without org_id",
140+
level="debug",
141+
)
136142

137143
except Exception:
138144
api_access_logger.exception("api.access: Error capturing API access logs")

0 commit comments

Comments
 (0)