WIP feat(opentelemetry): Add SentryTraceProvider#21181
Draft
andreiborza wants to merge 25 commits into
Draft
Conversation
Contributor
size-limit report 📦
|
0f2020a to
71e7c69
Compare
mydea
reviewed
May 27, 2026
| */ | ||
| public recordException(_exception: unknown, _time?: number | undefined): void { | ||
| // noop | ||
| public recordException(exception: unknown, time?: SpanTimeInput | undefined): void { |
Member
There was a problem hiding this comment.
I think we can leave this as noop, we do not care about this and do not really support it, doing nothing with events etc.
71e7c69 to
a44215e
Compare
cf369b6 to
749e7e7
Compare
f79c234 to
8ebaf6b
Compare
# Conflicts: # dev-packages/e2e-tests/test-applications/nextjs-13/instrumentation.ts # dev-packages/e2e-tests/test-applications/nextjs-14/instrumentation.ts # dev-packages/e2e-tests/test-applications/nextjs-15-basepath/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-15-intl/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-15/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16-streaming/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16-trailing-slash/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16-tunnel/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16-userfeedback/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-16/sentry.server.config.ts # dev-packages/e2e-tests/test-applications/nextjs-app-dir/instrumentation.ts # dev-packages/e2e-tests/test-applications/nextjs-pages-dir/instrumentation.ts # dev-packages/e2e-tests/test-applications/supabase-nextjs/sentry.server.config.ts
SentryNonRecordingSpan can now store a `sampled` flag that distinguishes "sampled negative" from "no sampling decision yet" in TwP mode. Trace header generation uses the new `spanToTraceSamplingDecision` helper to propagate this decision instead of always inferring from traceFlags. Also aligns `recordException` signature to use `SpanTimeInput` on both the Span interface and its implementations. Co-Authored-By: Claude <noreply@anthropic.com>
8ebaf6b to
2b70730
Compare
959483b to
87ed1f0
Compare
Co-Authored-By: Claude <noreply@anthropic.com>
In Tracing without Performance mode, a root non-recording span froze a DSC whose `transaction` was always the local span name, overwriting the frozen transaction of a continued trace. Keep the incoming/derived transaction and only fall back to the local span name when there is none. Co-Authored-By: Claude <noreply@anthropic.com>
Explain that the getter exists so the generic `spanToJSON` fallback can surface `parent_span_id` for non-recording spans. Co-Authored-By: Claude <noreply@anthropic.com>
…ir parent When tracing is suppressed, `_createNonRecordingSpan` copied only the parent's `traceId` and dropped its `spanId`, so a child span under a suppressed active parent did not carry `parent_span_id` in span JSON or trace headers. Pass the parent `spanId` as `parentSpanId` so the parent link is preserved. Co-Authored-By: Claude <noreply@anthropic.com>
…otSpan The scope-capture move into `_startRootSpan`/`_startChildSpan` left the non-recording return paths (tracing disabled, ignored spans, and the no-client child) without captured scopes. SentryTraceProvider.startActiveSpan reads those scopes to fork the isolation scope onto the OTel context, so attach them on every span returned from createChildOrRootSpan. Co-Authored-By: Claude <noreply@anthropic.com>
…istration
The provider called `setIsSetup('SentryTraceProvider')` in its constructor,
before `trace.setGlobalTracerProvider` ran. If registration failed (another
tracer provider already registered), setup validation still treated the minimal
provider as configured while the global tracer was a different implementation,
skipping the required SentrySpanProcessor/SentrySampler checks. Move the marking
to `setupSentryTraceProvider` after a successful registration.
Co-Authored-By: Claude <noreply@anthropic.com>
Align idle spans and `startSpan`/`startInactiveSpan` in Tracing without
Performance mode: when continuing a trace, freeze the incoming DSC as-is (even
an empty `{}` from a `sentry-trace` header without baggage) instead of merging
in the local span name or fabricating client fields. Only a new trace derives
the DSC from the client and attaches the local span name. Idle spans now defer
the sampling decision in TwP like `startSpan`.
Co-Authored-By: Claude <noreply@anthropic.com>
When tracing is suppressed, `startSpan` returns `_createNonRecordingSpan` directly, bypassing the `_INTERNAL_startInactiveSpan`/`createChildOrRootSpan` path where scopes are captured. As a result `startActiveSpan` read no captured isolation scope and couldn't fork it onto the OTel context, breaking scope isolation for work inside suppressed active spans. Capture the current scope and isolation scope on the non-recording span, mirroring `createChildOrRootSpan`. Co-Authored-By: Claude <noreply@anthropic.com>
In Tracing without Performance mode `startIdleSpan` builds a non-recording placeholder and freezes its DSC but never attached the current/isolation scopes, unlike the parallel non-recording paths in `createChildOrRootSpan`. Capture them so consumers like SentryTraceProvider can read the scopes off the placeholder. Co-Authored-By: Claude <noreply@anthropic.com>
… spans Non-recording child spans (unsampled) and ignored spans now carry their parent's span id, so `spanToJSON` surfaces `parent_span_id` for them. Also store captured scopes on the TwP placeholder in `startSpan`/`startSpanManual`. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5917bab. Configure here.
Mirror `getDynamicSamplingContextFromSpan`: when a TwP placeholder span's source is "url", omit the local span name from the frozen DSC (URLs may contain PII). Applies to both `createChildOrRootSpan` and `startIdleSpan`. Co-Authored-By: Claude <noreply@anthropic.com>
…sEvent In the SentryTraceProvider transaction `preprocessEvent` hook, the response context spread `...event.contexts.response` after setting `status_code` from `http.response.status_code`, so a pre-existing `response.status_code` overrode the span-derived value. Spread the existing response first so the span-derived status_code wins. Co-Authored-By: Claude <noreply@anthropic.com>
Add an `includeTransaction` option to the `eventEnvelope` helper and use it where the http.server span source is `url` (the TwP DSC omits the span name as raw URLs may contain PII). Adds a dedicated dsc-url-source suite proving the name is absent from the DSC even when tracing is enabled and a transaction is recorded. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

WIP