fix: propagate OTEL alias span attributes in AuthORWrapper#7758
fix: propagate OTEL alias span attributes in AuthORWrapper#7758
Conversation
…auth APIs When an API uses multiple security requirements in compliant mode (e.g., JWT OR API Key), the AuthORWrapper middleware orchestrates authentication. Inner auth middlewares store span attributes under their own name (e.g., "JWTMiddleware"), but TraceMiddleware looks for attributes under "AuthORWrapper" — causing the tyk.api.apikey.alias attribute to be missing from OTEL spans. This fix propagates span attributes from the successful inner middleware to the AuthORWrapper name after authentication succeeds, so TraceMiddleware can apply them to the OTEL span. Co-Authored-By: Claude Opus 4.6 <[email protected]>
🚨 Jira Linter FailedCommit: The Jira linter failed to validate your PR. Please check the error details below: 🔍 Click to view error detailsNext Steps
This comment will be automatically deleted once the linter passes. |
|
API Changes no api changes detected |
|
This PR fixes a bug where OpenTelemetry (OTEL) span attributes, such as The fix introduces logic within the Files Changed Analysis
Architecture & Impact AssessmentWhat this PR accomplishes: Key technical changes introduced:
Affected system components:
Flow Diagram: sequenceDiagram
participant Client
participant AuthORWrapper
participant "InnerAuth (e.g., APIKey Middleware)" as InnerAuth
participant TraceMiddleware
Client->>AuthORWrapper: Request with API Key
AuthORWrapper->>InnerAuth: ProcessRequest()
InnerAuth-->>AuthORWrapper: Success, sets span attributes under its own context key
Note over AuthORWrapper: **New Logic:** Copies attributes from InnerAuth's key to its own key
AuthORWrapper->>TraceMiddleware: Continue request processing
TraceMiddleware->>TraceMiddleware: Creates OTEL span, reads attributes from AuthORWrapper's key
Note over TraceMiddleware: Span now correctly includes `tyk.api.apikey.alias`
Scope Discovery & Context ExpansionThe change is well-contained within the The impact is limited to APIs using the compliant security processing mode with multiple authentication schemes ( Metadata
Powered by Visor from Probelabs Last updated: 2026-02-10T14:44:06.079Z | Triggered by: pr_opened | Commit: 3016ef6 💡 TIP: You can chat with Visor using |
✅ Security Check PassedNo security issues found – changes LGTM. ✅ Architecture Check PassedNo architecture issues found – changes LGTM. Performance Issues (1)
Quality Issues (2)
Powered by Visor from Probelabs Last updated: 2026-02-10T14:44:13.075Z | Triggered by: pr_opened | Commit: 3016ef6 💡 TIP: You can chat with Visor using |
Summary
tyk.api.apikey.alias) from inner auth middlewares to theAuthORWrappername in compliant mode multi-auth APIsAuthORWrapperorchestrates authentication (JWT OR API Key), inner middlewares store span attributes under their own name (e.g.,JWTMiddleware), butTraceMiddlewarelooks for attributes underAuthORWrapper— causing them to be missing from OTEL spansAuthORWrappernameTest plan
TestCompliantMode_OtelAliasAttributeunit test verifying span attribute propagation for both JWT and API key auth through AuthORWrappergo build ./gateway/andgo vet ./gateway/passgo test -c ./gateway/)TestCompliantMode_JWTOrAPIKeyOrHMACand other compliant mode tests unaffected🤖 Generated with Claude Code