Skip to content

Correlate Sentry errors with OTel traces#1320

Merged
RhysSullivan merged 2 commits into
mainfrom
feat/sentry-otel-trace-join
Jul 4, 2026
Merged

Correlate Sentry errors with OTel traces#1320
RhysSullivan merged 2 commits into
mainfrom
feat/sentry-otel-trace-join

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Why

Sentry error events and the OTel traces exported to Axiom carried unrelated trace ids: Sentry mints its own trace context while the app owns a separate WebTracerProvider, so going from an error event to its request trace (or back) required manual timestamp and attribute joins during incident debugging.

Change

Minimal bidirectional tag join, no trace-context unification:

  • Every outgoing Sentry event gets otel_trace_id and otel_span_id tags from the active OTel span (beforeSend for auto-captured errors, plus an Effect-aware capture helper for explicit captures).
  • Explicit captures annotate the active OTel span with a sentry.event_id attribute for the reverse lookup.
  • Scattered direct Sentry.captureException call sites migrated to the shared helper so they all carry the tags.
  • DO-side captures stitch the worker-propagated trace parent, so session DO errors correlate too; paths with no active span leave the tags unset rather than inventing ids.

Full unification (Sentry adopting the OTel trace id as its own) was rejected: the app deliberately opts out of Sentry OTel mode and owns its tracer provider; Sentry Cloudflare OTel mode replaces the global provider and documents no support for custom context handling.

Verification

  • Unit tests for the tagging helpers.
  • New e2e scenario (env-gated synthetic error route, only mounted when SENTRY_OTEL_VERIFY=true in the e2e stack) asserting the captured event id, trace id, and span id match between the Sentry payload and the exported span.
  • Typecheck, cloud build, format all green.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 086bfa5 Jul 04 2026, 09:56 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 086bfa5 Commit Preview URL

Branch Preview URL
Jul 04 2026, 09:55 AM

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

@pkg-pr-new

pkg-pr-new Bot commented Jul 4, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1320

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1320

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1320

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1320

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1320

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1320

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1320

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1320

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1320

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1320

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1320

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1320

executor

npm i https://pkg.pr.new/executor@1320

commit: 03c1c2f

@RhysSullivan RhysSullivan merged commit 4a84b0d into main Jul 4, 2026
20 checks passed
@RhysSullivan RhysSullivan deleted the feat/sentry-otel-trace-join branch July 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant