diff --git a/src/assets/images/workers/changelog/jsrpc-session-spans.png b/src/assets/images/workers/changelog/jsrpc-session-spans.png new file mode 100644 index 00000000000..0e4d95ad831 Binary files /dev/null and b/src/assets/images/workers/changelog/jsrpc-session-spans.png differ diff --git a/src/content/changelog/workers/2026-09-10-javascript-rpc-session-spans.mdx b/src/content/changelog/workers/2026-09-10-javascript-rpc-session-spans.mdx new file mode 100644 index 00000000000..a6440a536de --- /dev/null +++ b/src/content/changelog/workers/2026-09-10-javascript-rpc-session-spans.mdx @@ -0,0 +1,16 @@ +--- +title: Workers traces now include JavaScript RPC session spans +description: Workers traces now include JavaScript RPC session spans for Worker-to-Worker and Worker-to-Durable Object calls. +products: + - workers + - durable-objects +date: 2026-09-10 +--- + +Workers traces can now follow JavaScript RPC calls across Worker boundaries and into Durable Objects. Previously, a trace stopped at the caller's RPC boundary. The dashboard now shows the caller-side session and method calls alongside the callee invocation, nested calls, and callbacks into another Worker. + +A session span covers the lifetime of a caller-side session and groups calls that reuse it. Individual call spans show each method invocation. Execution colors distinguish the Workers or Durable Object entrypoints involved, while arrows mark outgoing and incoming calls. Together, these details show where time was spent, which calls reused a session, and how returned stubs and callbacks fit into the request. + +![A Workers trace of a Worker-to-Worker RPC session, showing the session span, the caller's getCounter and increment call spans, and the callee's invocation and matching call spans](~/assets/images/workers/changelog/jsrpc-session-spans.png) + +[Tracing must be enabled](/workers/observability/traces/#how-to-enable-tracing) in your Wrangler configuration for these spans to be recorded. For supported spans and attributes, refer to [Spans and attributes](/workers/observability/traces/spans-and-attributes/). diff --git a/src/content/docs/workers/observability/traces/index.mdx b/src/content/docs/workers/observability/traces/index.mdx index 1503a0db215..16963574e39 100644 --- a/src/content/docs/workers/observability/traces/index.mdx +++ b/src/content/docs/workers/observability/traces/index.mdx @@ -28,6 +28,7 @@ Cloudflare Workers provides tracing instrumentation **out of the box** — no co - **Fetch calls** — All outbound HTTP requests, capturing timing, status codes, and request metadata. This enables you to quickly identify how external dependencies affect your application's performance. - **Binding calls** — Interactions with various Worker bindings such as KV reads and writes, R2 object storage operations and Durable Object invocations. +- **RPC calls** — Calls between Workers and Durable Objects, including caller-side session spans and individual method-call spans. - **Handler calls** — The complete lifecycle of each Worker invocation, including triggers such as [fetch handlers](/workers/runtime-apis/handlers/fetch/), [scheduled handlers](/workers/runtime-apis/handlers/scheduled/), and [queue handlers](/queues/configuration/javascript-apis/#consumer). diff --git a/src/content/docs/workers/observability/traces/spans-and-attributes.mdx b/src/content/docs/workers/observability/traces/spans-and-attributes.mdx index a3141c936f2..c2d5d9a8c20 100644 --- a/src/content/docs/workers/observability/traces/spans-and-attributes.mdx +++ b/src/content/docs/workers/observability/traces/spans-and-attributes.mdx @@ -147,7 +147,7 @@ Cloudflare Workers provides automatic tracing instrumentation **out of the box** #### [`RPC Handler`](/workers/runtime-apis/rpc/) -- `cloudflare.jsrpc.method` +- `jsrpc.method` #### [`Email Handler`](/email-service/api/route-emails/email-handler/) @@ -165,6 +165,27 @@ Cloudflare Workers provides automatic tracing instrumentation **out of the box** --- +### [RPC](/workers/runtime-apis/rpc/) + +Workers tracing emits these spans for RPC calls between Workers and from Workers to Durable Objects. + +#### RPC session + +A caller-side span that covers the lifetime of an RPC session. Calls that reuse the session appear under this span. + +This span has no additional RPC-specific attributes. + +#### RPC call + +A caller-side or callee-side span for an individual method call or property access. + +- `jsrpc.method` - The method name or property path +- `jsrpc.operation` - The operation type: `call` or `getProperty` +- `jsrpc.target_kind` - The type of RPC target +- `jsrpc.caller_span_id` - On callee-side spans, the corresponding caller-side `jsRpcCall` span ID + +--- + ### [D1](/d1/) #### Attributes available on all D1 spans