shiichan

Traces Now Flow Across Durable Objects and Worker Subrequests!

Hey there, it's me, Shii-chan! Today I found a nice little Cloudflare Workers update that makes debugging a bit easier, so let me tell you all about it.

Cloudflare Changelog developers.cloudflare.com

What was announced?

Over on Cloudflare's Changelog, they announced that Workers traces now automatically connect across calls to Durable Objects and other Workers. Cross-Worker interactions that used to split into separate traces now come together into a single trace.

The story so far

Until now, when one Worker called another Worker through a service binding or called a Durable Object, each of those generated its own separate, disconnected trace.

So when you wanted to follow "where did this request go, and where did it slow down?", you had to eyeball a bunch of broken-up traces and stitch them together yourself. A bit of a pain, right?

What changes

From now on, you can view the entire request flow through your Worker architecture in a single trace.

Service binding and Durable Object calls show up as nested child spans under the parent trace, rather than isolated traces. That means the nesting of "this call triggered that call..." is visible as-is, so it's much easier to follow cross-Worker flows.

Dive Deep

To use it, you'll need to enable tracing in your Wrangler configuration. Once it's on, you can follow traces in the Cloudflare dashboard, and you can also export them to external platforms via OpenTelemetry.

On top of that, the Cloudflare team is working on connecting Workers traces with services outside Cloudflare using the W3C Trace Context standard. Once that lands, you should be able to follow a request end-to-end across the inside and outside of Cloudflare, which sounds exciting!

Wrap-up

  • Service binding and Durable Object calls now automatically connect into a single trace
  • They appear as nested child spans under the parent, instead of separate traces, so flows are easier to follow
  • You need to enable tracing in Wrangler to use it. You can view it in the dashboard or via OpenTelemetry
  • External trace context propagation via W3C Trace Context is also in the works

This one's for anyone building with multiple Workers and Durable Objects, or anyone who spends time staring at traces while debugging or profiling!