feat: Add authenticated environment attributes to relay.auth span and metrics - #781
Open
keelerm84 wants to merge 2 commits into
Open
feat: Add authenticated environment attributes to relay.auth span and metrics#781keelerm84 wants to merge 2 commits into
keelerm84 wants to merge 2 commits into
Conversation
kinyoklion
reviewed
Jul 30, 2026
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.
Summary
Emit the authenticated environment as telemetry attributes so traces and metrics can be correlated by environment.
relay.authspan: on successful auth, both auth middlewares now setrelay.auth.environment.name(always, the human-readable display name) andrelay.auth.environment.id(only when anEnvironmentIDcredential is configured). Therelay.auth.result=successattribute remains unconditional.environment.nameand now also emitsenvironment.idwhen available.The environment ID may be absent for SDK-key-only environments in a manual configuration, so it is only added when present.
Note
Low Risk
Additive telemetry and an internal metrics API signature change; no auth or request-handling behavior changes beyond extra span attributes.
Overview
Adds environment identity to OpenTelemetry so traces and per-environment metrics can be correlated beyond display name alone.
On successful auth, both
SelectEnvironmentByAuthorizationKeyandSelectEnvironmentByClientSideAuthsetrelay.auth.environment.name(display name) and, when configured,relay.auth.environment.idon therelay.authspan via a sharedauthEnvSpanAttributeshelper.environment.idis omitted for SDK-key-only manual configs where no environment ID exists.Metrics extend
Manager.AddEnvironmentwith anenvIDargument; the environment attribute set still includesenvironment.nameand now addsenvironment.idwhen non-empty. Environment startup passesenvConfig.EnvIDfromenv_context_impl.Tests cover presence/absence of
environment.idon metric attributes; existingAddEnvironmentcall sites pass an empty ID where appropriate.Reviewed by Cursor Bugbot for commit 70b8963. Bugbot is set up for automated code reviews on this repo. Configure here.