# Workers - Workers tracing — new getActiveSpan(), recordException(), startSpan(), and setAttributes() APIs

Publisher-attributed story with a reviewed brief or permitted publisher paragraph. The original publisher is responsible for the linked reporting.

- Publisher: Cloudflare Developers
- Category: Cloud
- Original publication time: 2026-09-25T00:00:00Z
- First observed by NexusTechWire: 2026-10-01T15:54:33Z
- Original source: https://developers.cloudflare.com/changelog/post/2026-09-25-custom-span-apis/
- NexusTechWire record: https://nexustechwire.com/news/news-560583c732831410c207

## From the publisher

Custom spans in Workers now support more of the OpenTelemetry span API, so you can instrument more of your code and record errors directly on your spans. tracing.startSpan(name) creates a span without making it the active span, and returns it. Other spans do not nest under it. Call span.end() when the operation is complete. tracing.getActiveSpan() returns the currently active span. Use it to annotate the current span from helper functions and libraries without passing the span object through your code. Outside any custom span, it returns the invocation's root span. span.recordException(exception) records an exception event on a span. It accepts an Error, a string, or an object with a code, name, or message. span.setAttributes(attributes) sets multiple attributes at once. setAttribute() and setAttributes() now return the span, so you can chain calls.

Source license: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Publisher excerpt shortened and converted to plain text. Original source license applies.

Read the full original: [Cloudflare Developers](https://developers.cloudflare.com/changelog/post/2026-09-25-custom-span-apis/)

This record does not reproduce the complete article or represent independent confirmation of every source claim.
