Skip to content

Pin production SENTRY_TRACES_SAMPLE_RATE to 0 now that OTLP export delivers traces - #906

Merged
kody-bot merged 1 commit into
mainfrom
cursor/sentry-sdk-traces-off-837c
Jul 24, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/sentry-sdk-traces-off-837c

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

What

Follow-up to #905. The sentry-otlp-traces export destination is confirmed delivering (Sentry's spans dataset for kody-cloudflare shows Cloudflare-exported spans with no SDK attribution), so this pins SENTRY_TRACES_SAMPLE_RATE: 0 as a JSON-number Wrangler var in the production environment to stop the in-Worker Sentry SDK from producing a duplicate set of traces. Error capture is unaffected.

Also corrects the docs: they previously said to set a Worker secret, but buildSentryOptions reads the raw runtime env and only honors typeof === 'number' — a string secret "0" would be silently ignored. The var must be a JSON number, which is what production now sets. worker-configuration.d.ts is regenerated (npm run generate-types).

Verification

  • npm run typecheck passes with the regenerated types (literal 0 merges with AppEnv's number | undefined).
  • npx wrangler deploy --dry-run --env production shows env.SENTRY_TRACES_SAMPLE_RATE (0) bound as a number.
  • Pre-push ran 1289 unit tests + 18 Playwright E2E: green.
System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ 0d2a36fa · Head: branch tip

Classification: composes — one production Wrangler var plus doc corrections and regenerated types; no primitives added or changed, no runtime code paths modified.

Primitives touched

None — the Sentry SDK already supported this var; production config now sets it.

Before / after

// packages/worker/wrangler.jsonc env.production.vars — before
"SENTRY_ENVIRONMENT": "production",

// after
"SENTRY_ENVIRONMENT": "production",
"SENTRY_TRACES_SAMPLE_RATE": 0, // JSON number; SDK ignores string secrets
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added production configuration to prevent duplicate Sentry performance traces while preserving error reporting.
    • Added runtime configuration for disaster-recovery export and backup settings.
  • Documentation

    • Clarified Sentry trace sampling behavior, configuration requirements, and its relationship to native tracing.
    • Updated setup and environment-variable guidance for production deployments.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c2943d9-a229-4ea0-94ff-93d99e93058e

📥 Commits

Reviewing files that changed from the base of the PR and between 0d2a36f and c16d4d3.

📒 Files selected for processing (5)
  • docs/contributing/architecture/request-lifecycle.md
  • docs/contributing/environment-variables.md
  • docs/contributing/setup-manifest.md
  • packages/worker/worker-configuration.d.ts
  • packages/worker/wrangler.jsonc

📝 Walkthrough

Walkthrough

Production pins SENTRY_TRACES_SAMPLE_RATE to numeric 0 in Wrangler configuration, with documentation explaining native OTLP tracing and SDK duplicate prevention. Generated worker environment typings are updated for tracing, disaster-recovery, and Stripe binding changes.

Changes

Sentry tracing configuration

Layer / File(s) Summary
Production trace sampling configuration
packages/worker/wrangler.jsonc, docs/contributing/environment-variables.md, docs/contributing/architecture/request-lifecycle.md, docs/contributing/setup-manifest.md
Production sets SENTRY_TRACES_SAMPLE_RATE to numeric 0; documentation describes the JSON-number var requirement, native OTLP tracing, error capture, and duplicate SDK traces.

Worker environment typing updates

Layer / File(s) Summary
Worker environment typing updates
packages/worker/worker-configuration.d.ts
Generated metadata and environment declarations are updated with Sentry and disaster-recovery bindings, a literal Stripe price ID, and removal of two Stripe bindings from ProcessEnv.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • kentcdodds/kody#905: Updates Workers native tracing and OTLP-to-Sentry guidance related to duplicate trace avoidance.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: pinning production SENTRY_TRACES_SAMPLE_RATE to 0 because OTLP export already delivers traces.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-sdk-traces-off-837c

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kody-bot
kody-bot marked this pull request as ready for review July 24, 2026 06:30
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-906.kody-a99.workers.dev

Worker: kody-pr-906
D1: kody-pr-906-db
KV: kody-pr-906-oauth-kv

Mocks:

@kody-bot
kody-bot merged commit 66d6e32 into main Jul 24, 2026
7 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-sdk-traces-off-837c branch July 24, 2026 06:40
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.

3 participants