@devries-cameron20 / t3code-1 / commits / 02a177620a
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

feat(relay): show time to connected and its phases on the relay dashboard (#22083)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 19, 2026 at 19:31 UTC 02a177620a60ce870993b732c8a8b8261309da7e
2 files changed +53
docs/operations/relay-observability.md
+6
@@ -121,6 +121,12 @@ Monitors count HTTP status codes, not span errors. A request the relay cuts off
121 ends as an interrupted span without an error flag, but still answers 504. `/connect` 502s are
122 normal: offline hosts produce most of them, retried by their clients every few seconds.
123
124 +The dashboard's "Connecting" charts show connections as users see them. Web, desktop, and mobile
125 +export a root `relay.connection.attempt` span per attempt, which lasts until initial sync finishes, in
126 +the same trace as the relay's and the host's spans. Most reconnects reuse a cached relay token and go
127 +straight to the host, so relay latency only affects cold connects. A slow total with fast phases
128 +usually means the client waited out an unreachable direct (LAN) route before falling back to the relay.
129 +
130 **Links failing / tunnel recovery failing.** Open the dashboard's "Link failures by reason" table.
131 `provisioning: ensure-tunnel` or `configure-tunnel` with Cloudflare 429s on the "Cloudflare API calls
132 by status" chart is the #16810 failure: the account's Cloudflare API rate limit. Ask Cloudflare to
infra/relay/src/monitoring.ts
+47
@@ -193,6 +193,7 @@ const relayDashboardCharts = (dataset: string): ReadonlyArray<QueryChart> => {
193 const source = `['${dataset}']`;
194 const linkRequests = `${source}\n| where kind == "server" and ['attributes.http.request.method'] == "POST" and ['attributes.http.route'] == ${LINK_ROUTE}`;
195 const tunnelRequests = `${source}\n| where kind == "server" and ['attributes.http.request.method'] == "POST" and ['attributes.http.route'] in (${TUNNEL_ROUTES})`;
196 + const clientConnections = `${source}\n| where name == "relay.connection.attempt" and error != true\n| extend surface = tostring(['resource.custom']['t3.client.surface'])\n| where isnotempty(surface)`;
197 return [
198 timeSeries(
199 "links",
@@ -242,6 +243,52 @@ const relayDashboardCharts = (dataset: string): ReadonlyArray<QueryChart> => {
243 apl: `${source}\n| where name == "relay.environment_linker.link" and error == true\n| extend message = tostring(['status.message'])\n| summarize failures = count() by reason = case(message contains "failed during '", strcat("provisioning: ", extract("failed during '([^']+)'", 1, message)), message startswith "Managed tunnel limit reached", "managed tunnel limit reached", substring(message, 0, 80))\n| top 10 by failures`,
244 },
245 },
246 + // Connecting, as users see it: web, desktop and mobile export their
247 + // connection spans into this dataset, in the same traces as the relay's
248 + // and the host's spans. An attempt lasts until initial sync finishes.
249 + timeSeries(
250 + "connect-time",
251 + "Connecting: time to connected by surface (ms)",
252 + `${clientConnections}\n| summarize p50 = percentile(duration, 50) / 1000000, p90 = percentile(duration, 90) / 1000000 by bin_auto(_time), surface`,
253 + ),
254 + timeSeries(
255 + "connect-outcomes",
256 + "Connecting: attempts by outcome",
257 + `${source}\n| where name == "relay.connection.attempt" and isnotempty(['resource.custom']['t3.client.surface'])\n| summarize connected = countif(error != true), failed = countif(error == true) by bin_auto(_time)`,
258 + ),
259 + {
260 + id: "connect-phases",
261 + name: "Connecting: where the time goes (ms)",
262 + type: "Table",
263 + query: {
264 + // Failed direct route checks stay in: waiting out an unreachable LAN
265 + // address before falling back to the relay is the slowest step.
266 + apl: [
267 + source,
268 + `| where isnotempty(['resource.custom']['t3.client.surface'])`,
269 + `| extend url = tostring(['attributes.url.full'])`,
270 + `| extend phase = case(`,
271 + ` name == "ConnectionDriver.checkRoute", "0. Direct route check, before any relay fallback",`,
272 + ` name == "relay.connection.cloudSessionToken.resolve", "1. Clerk session token",`,
273 + ` name == "clientRuntime.managedRelay.exchangeAccessToken", "2. Relay token exchange",`,
274 + ` kind == "client" and url startswith "https://relay.t3.codes/v1/environments/" and url endswith "/connect", "3. Relay connect, minting a host credential",`,
275 + ` name == "environment.authorization.descriptor", "4. Host descriptor",`,
276 + ` name == "environment.authorization.accessToken.exchange", "5. Host token exchange",`,
277 + ` name == "clientRuntime.connection.remote.createDpopSocketUrl", "6. Socket ticket",`,
278 + ` name == "environment.initialSync", "7. Initial sync",`,
279 + ` name == "relay.connection.attempt", "Total: time to connected",`,
280 + ` "")`,
281 + `| where phase != "" and (error != true or phase startswith "0.")`,
282 + `| summarize calls = count(), p50_ms = round(percentile(duration, 50) / 1000000, 0), p90_ms = round(percentile(duration, 90) / 1000000, 0) by phase`,
283 + `| order by phase asc`,
284 + ].join("\n"),
285 + },
286 + },
287 + timeSeries(
288 + "relay-latency-by-continent",
289 + "Relay token and connect latency by user continent (p50 ms)",
290 + `${source}\n| where kind == "server" and ['attributes.http.request.method'] == "POST" and (['attributes.http.route'] == "/v1/client/dpop-token" or ['attributes.http.route'] == "/v1/environments/:environmentId/connect")\n| extend continent = tostring(['attributes.custom']['relay.edge.continent'])\n| where isnotempty(continent)\n| summarize p50 = percentile(duration, 50) / 1000000 by bin_auto(_time), continent`,
291 + ),
292 ];
293 };
294