Skip to content

Check the performance of all Cloudflare binding instrumentations #24778

Description

@JPeer264

Description

A SQL-heavy Durable Object workload showed a large CPU regression in @sentry/cloudflare 10.61.0, caused by instrumentation work on every storage.sql.exec() call. This showed that the per-call cost of our Cloudflare instrumentations was not checked in a structured way.

Go over all instrumentations in @sentry/cloudflare and check their CPU cost, with tracesSampleRate: 1 and with tracesSampleRate: 0:

  • Durable Object handlers and storage (SQL, KV, sync KV, alarms)
  • Worker handlers (fetch, scheduled, queue, email, tail)
  • Bindings (D1, R2, queue producer, service bindings and DO stubs, Workers AI)
  • Agents
  • Workflows

(follow up to #24655)

Activity

  1. linear-code commented on Sep 28, 2026

    @linear-code
  2. anirudhsama commented on Oct 9, 2026

    @anirudhsama

    We profiled a production Worker (~44M req/day, mostly small POST ingest) with Workers on-demand profiling, using @sentry/cloudflare 10.66 and tracesSampleRate: 0. The largest costs were per-request init() and OpenTelemetry tracer registration (fixed by cacheClient in v11, thanks) and request body capture (now gated by dataCollection.httpBodies).

    One cost that remains in 11.6.0 with tracing off: wrapRequestHandlerWithInit still builds http.server span attributes on every request (httpHeadersToSpanAttributes → filterKeyValueData over all headers, plus addRequest, culture context), even when the span can't be sampled. In our heap profiles those two functions were about 9% of sampled allocation bytes. It looks like the same pattern #24655 fixed for Durable Object SQL: skip building attributes when the span won't be sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions