Skip to content

Ai gateway observability/log token ai gateway - #74647

Open
alex-m-brown wants to merge 3 commits into
ai-gateway-observability/log-token-sentryfrom
ai-gateway-observability/log-token-ai-gateway
Open

Ai gateway observability/log token ai gateway#74647
alex-m-brown wants to merge 3 commits into
ai-gateway-observability/log-token-sentryfrom
ai-gateway-observability/log-token-ai-gateway

Conversation

@alex-m-brown

@alex-m-brown alex-m-brown commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The access token of the AI gateway had a user_id claim that held the raw user_id. This change removes the claim and puts a user_log_token claim in its place. The gateway can count and group its data for each user, but it never
receives a user id.

The log token uses the sentry destination, because the gateway sends its error reports and spans to Sentry. The dashboard uses the same destination for its own Sentry events. Therefore one log token identifies a user in the data of the dashboard and in the data of the gateway.

Links

Testing story

dashboard/test/controllers/ai_gateway_auth_controller_test.rb is a new file of tests

Deployment notes

Must merge after AI-Gateway PR: https://github.com/code-dot-org/ai-gateway/pull/47

Do not merge this pull request before these two conditions are true:

  1. The base branch ai-gateway-observability/log-token-sentry is merged. That branch adds Cdo::UserLogToken and the user_log_token_keys configuration.
  2. The gateway worker reads the user_log_token claim. This change removes the user_id claim. A worker that reads only user_id finds no value.

Set user_log_token_keys in each environment before deployment. If the key is absent, the module makes no token, the claim is null, and the gateway sees all, users as one user.

Privacy and security

The raw user id no longer goes to the AI gateway. It also no longer goes to the systems that receive data from the gateway.

alex-m-brown and others added 3 commits August 14, 2026 11:39
Replace the raw user id claim with a log token, so the AI gateway can key
rate limits and logs per user without ever seeing a user id.

Depends on the gateway worker reading the new claim; do not merge before
that worker is deployed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant