Repository navigation
Description
With CELLD_OTEL set, celld starts a span for each stateless Worker request (celld.fetch) and for each cell event, such as a cell's fetch (celld.cell_fetch). The handler that runs inside that span cannot learn the span's trace id or span id. The Request it receives carries the caller's headers unchanged, and no API exposes the current context.
celld does have the context. It links each console.* record to the handler's span, and it adds a child traceparent to outbound fetch() calls. Only handler code cannot see it.
Tested on v0.6.3 and on main at 8702f6d.
Why handlers need it
- To return the trace id to the caller, for example in a response header, so that a failed request can be found in the tracing backend. When the caller sends no
traceparent, the trace id exists only inside celld. - To record the trace id with data the handler writes, such as an audit row or an error body.
Without the context, the usual workaround makes things worse. The application makes up its own ids and sets traceparent on its outbound calls. celld keeps a traceparent the application sets instead of adding its own (crates/celld/js.rs:9131 in v0.6.3). The downstream service then joins a span that celld never exports, and the trace breaks at that call.
Reproduction
wrangler.json:
{
"name": "trace-probe",
"main": "worker.js",
"no_bundle": true,
"compatibility_date": "2026-01-01",
"vars": { "ECHO": "http://127.0.0.1:4318" },
"durable_objects": { "bindings": [{ "name": "PROBE", "class_name": "Probe" }] },
"migrations": [{ "tag": "v1", "new_sqlite_classes": ["Probe"] }]
}worker.js:
export class Probe {
async fetch(request) {
return Response.json({ cellSeen: request.headers.get("traceparent") });
}
}
export default {
async fetch(request, env) {
const seen = request.headers.get("traceparent");
console.log(JSON.stringify({ seen }));
// The capture server echoes the traceparent it receives.
const outbound = await (await fetch(`${env.ECHO}/echo`)).json();
const cell = await (await env.PROBE.get(env.PROBE.idFromName("p")).fetch(request)).json();
return Response.json({ workerSeen: seen, outbound: outbound.traceparent, ...cell });
},
};Run it with a capture server on port 4318. The server accepts OTLP/HTTP and answers GET /echo with the traceparent header it received. Then send one request without traceparent and one with it:
CELLD_OTEL=http://127.0.0.1:4318 CELLD_OTEL_FLUSH_MS=200 \
celld dev --port 9876 --no-watch --logs
curl -s http://127.0.0.1:9876/a
curl -s -H 'traceparent: 00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01' http://127.0.0.1:9876/bThe responses:
{"workerSeen":null,"outbound":"00-3f0e65fddc9f91ecd1bd6938795a3ee0-5db86e084bc2386b-01","cellSeen":null}
{"workerSeen":"00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01","outbound":"00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-d409ab6ef3bab277-01","cellSeen":"00-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-bbbbbbbbbbbbbbbb-01"}The spans celld exported, and what each handler saw:
| Request | Span | Trace id | Span id | What the handler saw |
|---|---|---|---|---|
/a, no traceparent |
celld.fetch |
3f0e65fddc9f91ecd1bd6938795a3ee0 |
95891994891e9485 |
Worker: null |
celld.cell_fetch |
same | 8196bd09af0db26f |
cell: null |
|
/b, caller's span bbbbbbbbbbbbbbbb |
celld.fetch |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa |
51496da8719cfd97 |
Worker: the caller's header |
celld.cell_fetch |
same | 454752b6805853a1 |
cell: the caller's header |
For /a, the console record carried trace 3f0e65fd… and span 95891994891e9485, the ids of celld.fetch. The trace id appears in the outbound header and the console record, but it never reaches handler code. For /b, the trace id matches, but neither handler can learn its own span id. Both see the caller's span, bbbbbbbbbbbbbbbb.
Expected
A fetch handler can read the trace id and span id of the span that celld runs it in.
Possible shapes
- Replace
traceparenton theRequestpassed to a Worker or cellfetchhandler with the context of that handler's span. A tracing proxy in front of the application would do the same. It needs no new API, and the handler code stays portable. This covers what we need. - Expose the current context through a celld API, for example on the execution context. This would also cover alarm, RPC, and WebSocket handlers, but code that uses it runs only on celld.
Either shape works for us.
Activity
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
telemetry, runtime: expose the handler traceparent (upstream #313) (0…
ryuzdev commentedon Nov 25, 2026
You can now read your span's trace context in Cello, the celld fork we maintain: handlers get
getCurrentTraceparent()from cloudflare:workers, so you can return the trace id to the caller or log it with the data you write. Ran your trace-probe against 0.3.1 — same trace id as the exported span, distinct span id per handler. ryuzcorp#75, in since 0.1.0. One caveat your report anticipated: an app-set traceparent still wins on outbound calls, so generate ids server-side — good to hear if this covers your audit-row case.