You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Add strict trace continuation support (#1016)
* feat: Add strict trace continuation support
Extract org_id from DSN host (e.g., o1234.ingest.sentry.io -> "1234")
and propagate it as sentry-org_id in outgoing baggage headers. Validate
incoming traces against the SDK's org_id to prevent cross-organization
trace mixing.
New configuration options:
- :org_id - explicit org ID override for self-hosted/Relay setups
- :strict_trace_continuation - when true, both org IDs must be present
and match to continue a trace (default: false)
Closes#1005
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: Import TestHelpers in strict trace continuation test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore: add strict trace continuation tests for baggage propagation
* fix: enhance logging for trace continuation org ID mismatch
* fix: add custom validation for org_id in config
* fix: improve logging for trace continuation org ID validation
* fix: prevent leading comma in baggage when injecting empty string
* refactor: simplify tests
* fix(tests): formatting
* refactor(e2e): improve env var handling in Playwright test suite
- Add `requireEnv()` helper in playwright.config.ts that throws when a
required env var is missing to make configuration errors explicit
- Use `??=` to set local dev defaults (localhost ports) before validation
so `npx playwright test` works out of the box without env vars
- Hoist PHOENIX_URL to file scope in tracing.spec.ts with an explicit
throw, removing the per-describe fallback declarations
- Replace the hardcoded 'http://localhost:4000' URL inside page.evaluate
with the file-scoped PHOENIX_URL constant
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(e2e): add strict trace continuation integration specs
Add three end-to-end Playwright specs covering the strict trace
continuation feature:
1. Matching org_id in baggage → incoming trace_id is preserved
2. Mismatched org_id in baggage → new trace_id is started
3. No org_id in baggage with strict=false → incoming trace_id is preserved
Supporting changes:
- Pass SENTRY_ORG_ID=123 via the webServer command in playwright.config.ts
so the Phoenix app starts with an org ID configured
- Read SENTRY_ORG_ID and SENTRY_STRICT_TRACE env vars in
phoenix_app/config/runtime.exs when SENTRY_E2E_TEST_MODE=true
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test(e2e): add strict trace continuation spec for strict=true with no org_id
Adds a 4th E2E spec covering the strict mode path where baggage carries
no sentry-org_id: with strict_trace_continuation=true a new trace must
be started rather than continuing the incoming one.
To enable per-test config toggling without a second server, adds a
PUT /sentry-test-config endpoint to the Phoenix app that calls
Sentry.put_config/2 for an allowlist of keys. A test.afterEach hook
resets strict_trace_continuation back to false after every test so the
setting cannot bleed between specs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ci): pass SENTRY_ORG_ID=123 when starting Phoenix server in e2e workflow
The strict trace continuation specs require the Phoenix app to have an
org ID configured so that mismatched/missing org IDs in incoming baggage
are correctly rejected. The webServer block in playwright.config.ts
already passes SENTRY_ORG_ID=123, but when SENTRY_E2E_SERVERS_RUNNING=true
that block is skipped and the server is started directly by CI - without
the env var, causing all rejection-path specs to fail.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix: strip empty sentry-org_id entries before appending SDK org_id to baggage
When incoming baggage contains a sentry-org_id= entry with an empty
value, extract_baggage_org_id/1 correctly returns nil (treating it as
absent). However, ensure_org_id_in_baggage/1 then appended a second
sentry-org_id=<sdk_value> entry, producing a duplicate key. A W3C
baggage parser on a downstream service would pick up the first (empty)
entry and ignore the valid one.
Fix by stripping any empty-valued sentry-org_id entries before appending
the SDK org ID, avoiding duplicate keys entirely.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Peter Solnica <peter@solnica.online>
0 commit comments