[codex] Trace first-party relay clients#2995
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🚀 Expo continuous deployment is ready!
|
34a5a25 to
a1779f7
Compare
ApprovabilityVerdict: Needs human review This PR introduces distributed tracing infrastructure across multiple applications and deployment pipelines. The scope includes new cloud resource provisioning, CI/CD modifications, and runtime integration in mobile, web, and server apps - warranting human review for the coordination and completeness of the feature. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Renewal drops relay trace headers
- Added
relayTraceHeaders: renewed.relayTraceHeadersto the options passed toensureSavedEnvironmentConnectionafter credential renewal, ensuring the connect trace fromrenewManagedRelayCredentialis propagated to the new websocket setup.
- Added
Or push these changes by commenting:
@cursor push f4367e9265
Preview (f4367e9265)
diff --git a/apps/web/src/environments/runtime/service.ts b/apps/web/src/environments/runtime/service.ts
--- a/apps/web/src/environments/runtime/service.ts
+++ b/apps/web/src/environments/runtime/service.ts
@@ -1601,6 +1601,7 @@
scopes: scopeHint,
serverConfig: options?.serverConfig ?? null,
allowManagedRenewal: false,
+ relayTraceHeaders: renewed.relayTraceHeaders,
});
}
}You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 03c78cc. Configure here.
There was a problem hiding this comment.
🟢 Low
When renewManagedRelayCredential succeeds in the auth error handling block (lines 1595-1604), the recursive call to ensureSavedEnvironmentConnection omits renewed.relayTraceHeaders. This causes the newly created client to use null instead of the fresh trace headers from the renewal, losing the tracing context for the connection attempt.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @apps/web/src/environments/runtime/service.ts around line 1599:
When `renewManagedRelayCredential` succeeds in the auth error handling block (lines 1595-1604), the recursive call to `ensureSavedEnvironmentConnection` omits `renewed.relayTraceHeaders`. This causes the newly created client to use `null` instead of the fresh trace headers from the renewal, losing the tracing context for the connection attempt.
Evidence trail:
apps/web/src/environments/runtime/service.ts lines 1595-1604 (recursive call omitting relayTraceHeaders); lines 1358-1402 (renewManagedRelayCredential returning relayTraceHeaders); line 1521 (default to null when not provided); line 1527 (relayTraceHeaders passed to createSavedEnvironmentClient); lines 1201-1204 (relayTraceHeaders used when resolving WebSocket URL); line 1957 (other caller that does pass relayTraceHeaders); lines 1218-1220 (renewal inside client resolver that properly passes renewed.relayTraceHeaders).
03c78cc to
4c38462
Compare
4c38462 to
f37abe6
Compare
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
f37abe6 to
fe78bce
Compare


Summary
Add product-owned OTLP tracing for first-party relay traffic without replacing the application's or user's global tracer.
RelayClientTracerandwithRelayClientTracingin@t3tools/shared/relayTracing--read-statesupport and inject deployed tracing configuration into release and hosted-web buildsThe tracing boundary is explicit: unrelated provider, server, and application spans continue using their existing tracer configuration.
Stack
mainReview this PR against
main. PR #2978 is stacked on top and adapts these tracing hooks to the rewritten connection runtime.Validation
vp checkvp run typecheckvp run lint:mobileNote
Medium Risk
Touches auth-adjacent relay broker minting and connection flows with trace propagation; ingest tokens are public but scoped, and misconfiguration could disable tracing or leak tokens into client bundles.
Overview
Adds product-owned OTLP tracing for first-party relay traffic via
@t3tools/shared/relayTracing:RelayClientTracer,withRelayClientTracing, andmakeRelayClientTracingLayerroute relay spans to a dedicated tracer without replacing the app’s global tracer.Runtime wiring: Web, mobile, server (broker + headless CLI), and
client-runtimemanaged-relay HTTP calls wrap relay work withwithRelayClientTracing. The server broker usestraceRelayBrokerHandlerto continue incomingtraceparentont3MintCredential. Web connection flows emit and carryrelayTraceHeadersthrough connect, renewal, and managed WebSocket ticket paths so downstream HTTP shares one trace id.Config & release: New
T3CODE_RELAY_CLIENT_OTLP_TRACES_*/VITE_RELAY_OTLP_TRACES_*resolution (runtime + build-time embed in server Vite). Relay infra provisions a client ingest token and exportsclientTracing*from Alchemy; deploy gains--read-stateand GitHub outputs. Release workflow reads prod relay state and injects tracing env into desktop, CLI, and Vercel web builds.Reviewed by Cursor Bugbot for commit fe78bce. Bugbot is set up for automated code reviews on this repo. Configure here.