Say Goodbye to Lost Durable Object Logs: Filter by Instance ID!
Hi everyone, it's Shiichan! Today I found an update that makes life easier if you use Durable Objects: it's now much simpler to find the logs and traces for a specific instance.
Cloudflare ChangelogWhat was announced?
On the Cloudflare Changelog, they announced an observability upgrade for Workers and Durable Objects. Workers Logs and OpenTelemetry spans for Durable Object requests now include the Durable Object instance ID.
The story so far
Until now, when you looked at logs or traces for Durable Objects, it was hard to tell at a glance which instance a given log entry belonged to, especially when many instances were running. If you had multiple instances of the same Durable Object class, logs could get mixed together and it was tricky to figure out "wait, whose log is this?"
What changes
Now you can follow the logs and traces for one specific instance.
- You can pull up logs for just the instance that's misbehaving
- Root spans and child spans carry the same ID, so you can correlate traces for one instance across the whole call
- Debugging stays clear even in environments running lots of instances
Dive Deep
The mechanism is simple: two fields were added.
- In Workers Logs, you can filter with
$workers.durableObjectId - In OpenTelemetry spans, the
cloudflare.durable_object.idattribute appears on both root and child spans with the same value
Using this ID, you can narrow the Workers Logs query builder or the trace search view down to a single instance's logs. For more detail, check the Durable Objects metrics and analytics docs and the Workers tracing spans and attributes docs.
Wrap-up
- Workers Logs and OpenTelemetry spans now include the Durable Object instance ID
- Filter with
$workers.durableObjectIdin Workers Logs, orcloudflare.durable_object.idin OpenTelemetry - You can correlate logs and traces per instance, which makes debugging much easier
This is great news if you run lots of Durable Object instances and need to track down why just one of them is acting up!