Ai gateway observability/log token sentry - #74644
Open
alex-m-brown wants to merge 9 commits into
Open
Conversation
Route Sentry's user context through UserLogToken at the single chokepoint in the observability engine, so user ids never reach Sentry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…teway-observability/log-token-sentry
…teway-observability/log-token-sentry
alex-m-brown
changed the base branch from
staging
to
ai-gateway-observability/user-log-token-lib
August 14, 2026 14:08
alex-m-brown
changed the base branch from
ai-gateway-observability/user-log-token-lib
to
ai-gateway-observability/log-token-admin-page
August 14, 2026 14:12
Route Sentry's user context through UserLogToken at the single chokepoint in the observability engine, so user ids never reach Sentry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
alex-m-brown
force-pushed
the
ai-gateway-observability/log-token-sentry
branch
from
August 14, 2026 14:13
dd1aee7 to
fd5b67d
Compare
…ithub.com/code-dot-org/code-dot-org into ai-gateway-observability/log-token-sentry
…gateway-observability/log-token-sentry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR sends Sentry the user log token instead of the raw user id.
A token is different for each destination, so you cannot match Sentry data against the data at another destination. A person who has the key can change a token back to a user id, but that person must use the admin page from PR #74619, and that page writes a record of each change.
dashboard/config/initializers/sentry.rb— the Wardenafter_fetchhook calledset_user_id(user.id). The hook now givesuser.idtoCdo::UserLogToken.derive, and gives only the result toset_user_token.dashboard/engines/observability/lib/observability/sentry.rb—set_user_idbecomesset_user_token. If the token is nil or empty, the method does nothing. The engine does not know the key. It only moves the token.README.mdandAGENTS.md— a new section, "User identification", and two rules: do not send a user id to Sentry, and do not add a path that changes a token back to a user id.Links
Cdo::UserLogToken)Testing story
Three new tests in
sentry_test.rbcoverset_user_tokenDeployment notes
Cdo::UserLogToken.derivegives nil if we do not configureuser_log_token_keys.set_user_tokenthen does nothing, and the Sentry event has no user. Configure the key in each environment before the release. If the key is absent, the events stay correct, but they show no user.Privacy and security
Sentry no longer receives user ids. This is the purpose of the change.
If the key is absent, the code sends no user. It does not send the user id instead.
Sentry can still receive an id through other paths. Sentry sends the contents of
contextandextra, the tags, and the OpenTelemetry attributes without a change, and there is nobefore_sendfilter on the Ruby side or the JavaScript side. This PR does not change these paths.