shiichan

Workers Traces Can Now Follow RPC Calls Between Workers!

Hey, it's me! I found an update today that's a small but genuinely useful one for anyone running Cloudflare Workers. It makes tracing distributed calls a lot less painful.

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, Workers traces now automatically include JavaScript RPC session spans! Previously, when a Worker called another Worker or a Durable Object over RPC, the trace stopped at the caller's RPC boundary. With this update, the dashboard now shows the caller-side session and method calls alongside the callee's invocation, nested calls, and callbacks back into another Worker, all in one place.

The story so far

Until now, when Workers called each other (or a Durable Object) over RPC, the trace would cut off right at the caller's side, so you couldn't see what happened on the callee's end. That made it hard to tell where time was actually being spent across an RPC boundary, whether a session was being reused, or how callbacks fit into the picture, just by looking at the trace.

What changes

From now on, you can follow an RPC call between Workers, or between a Worker and a Durable Object, as a single connected trace.

  • The caller's session and the callee's execution now appear side by side in the same trace
  • Nested calls and callbacks from the callee back into another Worker are shown too
  • You can see where time was spent and which calls reused a session

For engineers debugging or profiling RPC-heavy code, this makes it much easier to see the full picture across service boundaries.

Dive Deep

The trace is built mainly from two kinds of spans.

  • Session span: covers the lifetime of the caller-side session and groups together calls that reuse it
  • Call span: represents a single method invocation

On top of that, execution colors distinguish which Worker or Durable Object entrypoints are involved, and arrows mark outgoing and incoming calls. Together, these let you see where time was spent, which calls reused a session, and how returned stubs and callbacks fit into the request.

Enabling it is refreshingly simple: just add one setting to your Wrangler configuration file.

For JSON config (wrangler.jsonc):

{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "observability": {
    "traces": {
      "enabled": true
    }
  }
}

For TOML config (wrangler.toml):

[observability.traces]
enabled = true

You don't need to change your application code or add an observability SDK — once this setting is in place, Cloudflare records the spans automatically. For the supported spans and attributes, Cloudflare points to its Spans and attributes documentation.

Wrap-up

  • Workers traces now automatically include JavaScript RPC session spans
  • Traces used to stop at the caller's RPC boundary; now they follow the callee's execution, nested calls, and callbacks too
  • Session spans and call spans together show session reuse and per-method breakdowns
  • Enable it with observability.traces.enabled = true in your Wrangler config — no code changes or SDK needed
  • A great update for anyone debugging or profiling RPC calls between Workers and Durable Objects!