Skip to content

ref(o11y): Add scope.set_attribute in authentication#117405

Merged
sentrivana merged 2 commits into
masterfrom
ivana/set-attribute-authentication
Jun 12, 2026
Merged

ref(o11y): Add scope.set_attribute in authentication#117405
sentrivana merged 2 commits into
masterfrom
ivana/set-attribute-authentication

Conversation

@sentrivana

@sentrivana sentrivana commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
  • Supplements existing scope.set_tag() calls with equivalent scope.set_attribute() calls in src/sentry/api/authentication.py
  • This enables attributes-based telemetry (logs, metrics, spans v2) to inherit these values
  • Handles type mismatches: guards None entity_id and decodes bytes token_name

Once we switch to span streaming, the new attributes will get applied to spans automatically.

Related to getsentry/sentry-python#6537

Supplement existing scope.set_tag calls with equivalent scope.set_attribute
calls to support attributes-based telemetry (logs, metrics).
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 11, 2026
@sentrivana sentrivana changed the title feat: Add scope.set_attribute calls in authentication feat: Add scope.set_attribute in authentication Jun 11, 2026
@sentrivana sentrivana marked this pull request as ready for review June 11, 2026 11:39
@sentrivana sentrivana requested review from a team as code owners June 11, 2026 11:39
@sentrivana sentrivana requested a review from a team June 11, 2026 11:41

@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 1 potential issue.

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 c0f290e. Configure here.

Comment thread src/sentry/api/authentication.py Outdated
Comment thread src/sentry/api/authentication.py Outdated
@sentrivana sentrivana changed the title feat: Add scope.set_attribute in authentication ref(o11y): Add scope.set_attribute in authentication Jun 11, 2026
set_attribute expects string values, but api_token_type comes from
token_name which is ClassVar[bytes]. Decode bytes to str to prevent
potential crashes or data corruption.
@github-actions

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on 82e41ab in this run:

tests/sentry/api/helpers/test_deprecation.py::TestDeprecationDecorator::test_with_url_nameslog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/sentry/api/helpers/test_deprecation.py:243: in test_with_url_names
    assert resp.status_code == HTTP_200_OK
E   assert 410 == 200
E    +  where 410 = <Response status_code=410, "text/html; charset=utf-8">.status_code

@sentrivana sentrivana merged commit e2fea8d into master Jun 12, 2026
117 of 119 checks passed
@sentrivana sentrivana deleted the ivana/set-attribute-authentication branch June 12, 2026 08:36
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