Repository navigation
Enable Workers automatic tracing (OTel) and document OTLP export to Sentry - #905
Conversation
📝 WalkthroughWalkthroughWorkers tracing is configured to export through a Sentry OTLP destination. Documentation describes native tracing, setup requirements, fork behavior, sampling configuration, and disabling in-Worker trace capture after OTLP ingestion. ChangesWorkers tracing export
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
🔎 Preview deployed: https://kody-pr-905.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/contributing/setup-manifest.md`:
- Around line 75-80: Update the fork destination creation guidance in the setup
manifest to include the complete required POST payload: name, enabled,
configuration.type set to "logpush", configuration.url, configuration.headers,
and configuration.logpushDataset set to "opentelemetry-traces". Preserve the
existing dashboard instructions and warning about matching or removing the
destinations entry.
In `@packages/worker/wrangler.jsonc`:
- Around line 97-105: The top-level traces configuration currently sends preview
and test deployments to the production Sentry destination. Move
“sentry-otlp-traces” from the shared observability.traces.destinations
configuration into the production Wrangler environment, or replace it with
separately provisioned preview and test destinations while preserving tracing
for production.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f38072f9-4843-4cb6-9dee-f5d4032c6224
📒 Files selected for processing (4)
docs/contributing/architecture/request-lifecycle.mddocs/contributing/environment-variables.mddocs/contributing/setup-manifest.mdpackages/worker/wrangler.jsonc
What
observability.traces.enabledinpackages/worker/wrangler.jsonc. The runtime emits OTel-standard spans for handler invocations, outbound fetches, and binding calls (D1, KV, R2, Durable Objects, queues) with no SDK added to the bundle. Traces land in the Workers Observability dashboard next to the existing Workers Logs, andconsole.*output inside a span is attributed to that span.observability.traces.destinationsreferences the account-levelsentry-otlp-tracesdestination, which was created via the Cloudflare API (POST /accounts/{id}/workers/observability/destinations, datasetopentelemetry-traces) and points at thekody-cloudflareSentry project's OTLP traces endpoint with thex-sentry-authheader derived from the project DSN. Preview/test deploys inherit the top-level block without a destination, so their spans stay dashboard-only.request-lifecycle.mdgains a "Workers native tracing (OpenTelemetry)" section (billing/sampling notes included),setup-manifest.mdis the canonical destination/provisioning reference (with the full API payload forks need), andenvironment-variables.mdcanonically documents theSENTRY_TRACES_SAMPLE_RATE=0follow-up that avoids duplicate SDK traces. The other pages link out instead of restating, per the docs gardening principle.Why
Kody had no OpenTelemetry story: observability was Sentry SDK tracing, Workers Logs, structured
mcp-eventlines, and Analytics Engine usage metering. Native tracing adds request-flow visibility across the DO/D1/queue fan-out with zero runtime dependencies, and the OTLP export lands the same traces in Sentry alongside existing error reports.Notes
observabilityoverrides the top-level key wholesale, so the production block restatesenabled: true. Local dev and tests ignore observability config. The CI-generated production/preview configs are parsed from this file with only resource IDs rewritten, so the block carries through (tools/ci/resource-utils.ts,writeGeneratedWranglerConfig).head_sampling_ratedefaults to full sampling, fine at current traffic.SENTRY_TRACES_SAMPLE_RATE=0to stop duplicate SDK traces.Verification
npx wrangler deploy --dry-runpasses for bothproductionandpreviewenvs.npm run validatepassed in full (format, lint, typecheck, unit, Playwright E2E, MCP E2E, structure checks); pre-push re-ran 1289 unit tests + 18 E2E on each commit: green.GET /accounts/{id}/workers/observability/destinations:sentry-otlp-traces, datasetopentelemetry-traces, enabled.System recap — composes existing primitives (low risk)
Mode: recap · Base:
main@a73035bc· Head:6e84d3e8Classification: composes — no primitives added or changed. The diff touches only Worker platform configuration (
packages/worker/wrangler.jsonc) and contributor docs; the primitives classifier matches zero primitives. Runtime code paths are unchanged. The paired infrastructure change (thesentry-otlp-tracesOTLP destination) lives in the Cloudflare account, not the repo.Primitives touched
None — platform tracing is enabled in wrangler config and instrumented by the Workers runtime itself; no application primitive changes behavior.
Before / after
Summary by CodeRabbit
New Features
console.*output and export to Sentry via an account-level OTLP destination.Documentation
SENTRY_TRACES_SAMPLE_RATEguidance to prevent duplicate in-Worker trace emission after OTLP export is active (errors unaffected).