Skip to content

fix(core): Record span client report outcomes when discarding transactions - #25006

Open
Lms24 wants to merge 11 commits into
developfrom
lms/fix-core-span-outcomes
Open

Lms24 wants to merge 11 commits into
developfrom
lms/fix-core-span-outcomes

Conversation

@Lms24

@Lms24 Lms24 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

The client report spec calls for recording category span client outcomes, also if streaming is disabled. This PR makes the change to record outcomes for each span, including one for the transaction itself when a transaction is sampled negatively, as well as when it's dropped.

The transaction/event processing pipeline had a bunch of holes for discarded span counts, since any combination of ignoreSpans, event processors and beforeSendTransaction could drop child spans in any of those callbacks. So for example, a transaction that originally had 10 child spans and drops

  • 2 spans in ignoreSpans
  • 1 span in an event processor
  • the whole transaction in beforeSendTransaction

now all together reports 11 spans and 1 transaction outcome, with the correct reasons. No span drops are double-counted.

Related bugfix: Spans dropped by ignoreSpans without span streaming are now recorded as ignored instead of before_send.

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.85 kB +0.1% +29 B 🔺
@sentry/browser - with treeshaking flags 27.98 kB +0.11% +29 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 27.89 kB +0.09% +24 B 🔺
@sentry/browser (incl. Tracing) 51.92 kB +0.08% +38 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 51.94 kB +0.07% +36 B 🔺
@sentry/browser (incl. Tracing, Profiling) 54.88 kB +0.07% +38 B 🔺
@sentry/browser (incl. Tracing, Replay) 91.68 kB +0.04% +35 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.53 kB +0.03% +18 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 96.4 kB +0.05% +43 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 109.36 kB +0.03% +28 B 🔺
@sentry/browser (incl. Feedback) 47.38 kB +0.07% +33 B 🔺
@sentry/browser (incl. sendFeedback) 34.9 kB +0.11% +38 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.02 kB +0.09% +35 B 🔺
@sentry/browser (incl. Metrics) 30.89 kB +0.12% +35 B 🔺
@sentry/browser (incl. Logs) 31.17 kB +0.1% +29 B 🔺
@sentry/browser (incl. Metrics & Logs) 31.81 kB +0.1% +30 B 🔺
@sentry/react 31.69 kB +0.08% +25 B 🔺
@sentry/react (incl. Tracing) 54.25 kB +0.07% +36 B 🔺
@sentry/vue 37.93 kB +0.1% +36 B 🔺
@sentry/vue (incl. Tracing) 54.86 kB +0.09% +45 B 🔺
@sentry/svelte 29.88 kB +0.11% +32 B 🔺
@sentry/remix (Remix 3 client bundle) 56.95 kB +0.13% +72 B 🔺
CDN Bundle 31.59 kB +0.09% +26 B 🔺
CDN Bundle (incl. Tracing) 52.44 kB +0.09% +42 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.79 kB +0.09% +29 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 54.38 kB +0.06% +29 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.71 kB +0.04% +26 B 🔺
CDN Bundle (incl. Tracing, Replay) 90.1 kB +0.04% +29 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.03 kB +0.03% +20 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 96.26 kB +0.04% +32 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.22 kB +0.02% +18 B 🔺
CDN Bundle - uncompressed 93.08 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 155.69 kB +0.04% +57 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 99.61 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 161.65 kB +0.04% +57 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.65 kB +0.01% +22 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 275.86 kB +0.03% +57 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 281.8 kB +0.03% +57 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.56 kB +0.02% +57 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 295.49 kB +0.02% +57 B 🔺
@sentry/nextjs (client) 56.63 kB +0.07% +38 B 🔺
@sentry/sveltekit (client) 52.3 kB +0.06% +30 B 🔺
@sentry/core/server 40.91 kB +0.09% +36 B 🔺
@sentry/core/browser 13.74 kB +0.09% +12 B 🔺
@sentry/node 151.71 kB +0.03% +32 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.77 kB - -
@sentry/node - without tracing 94.28 kB +0.05% +40 B 🔺
@sentry/node - without channel injection 129.89 kB +0.03% +37 B 🔺
@sentry/aws-serverless 102.44 kB +0.02% +20 B 🔺
@sentry/cloudflare (withSentry) - minified 210.07 kB +0.03% +62 B 🔺
@sentry/cloudflare (withSentry) 520.99 kB +0.07% +329 B 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 227.74 kB +0.03% +62 B 🔺

View base workflow run

@Lms24

Lms24 commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread packages/core/src/utils/prepareEvent.ts
@Lms24 Lms24 self-assigned this Oct 2, 2026
@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch from e92e60e to d85d55a Compare October 5, 2026 11:08
@Lms24
Lms24 added this pull request to stack #25050 October 5, 2026 11:40
@Lms24 Lms24 changed the title fix(core): Record span client report outcomes if span streaming is disabled fix(core): Record span client report outcomes also when span streaming is disabled Oct 5, 2026
Comment on lines -373 to -374
client.recordDroppedEvent('sample_rate', 'span');

@Lms24 Lms24 Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is now handled via startSpan APIs

@Lms24
Lms24 marked this pull request as ready for review October 5, 2026 15:46
@Lms24
Lms24 requested review from a team as code owners October 5, 2026 15:46
@Lms24
Lms24 requested review from isaacs, msonnb and mydea and removed request for a team October 5, 2026 15:46
@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch from f6935b4 to 514d50a Compare October 5, 2026 17:51
@Lms24
Lms24 requested review from chargome and removed request for mydea October 6, 2026 08:49
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

👋 @isaacs, @msonnb — Please review this PR when you get a chance!

@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch 2 times, most recently from 932a210 to b2c14c7 Compare October 8, 2026 13:06
@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch from b2c14c7 to e80b42f Compare October 9, 2026 07:24

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e80b42f. Configure here.

Comment thread packages/core/src/client.ts
@Lms24 Lms24 changed the title fix(core): Record span client report outcomes also when span streaming is disabled fix(core): Record span client report outcomes when discarding transactions Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

👋 @chargome — Please review this PR when you get a chance!

Lms24 added a commit that referenced this pull request Oct 9, 2026
…d failures (#25185)

When sending an envelope fails (network error, 413, or a full buffer),
the transport recorded every item with quantity 1. This undercounts
span, log and metric discard quantities. Same for transactions that
[should
also](https://develop.sentry.dev/sdk/telemetry/client-reports/#span-outcomes)
report `span` counts. Containers now report their `item_count`, and
transactions also report `spans.length + 1` `span` outcomes, matching
how the client counts dropped transactions in `beforeSend`.

For transactions, we also record `span` outcomes on envelope send
failures, analogously to what
#25006 adds to other
discard reasons

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch from e80b42f to b54716b Compare October 9, 2026 12:23

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice change, thanks for the correction on transactions! I think some browser tests might still need an update but otherwise LGTM

dynamicSamplingContext?: Partial<DynamicSamplingContext>;
capturedSpanScope?: Scope;
capturedSpanIsolationScope?: Scope;
spanCountBeforeProcessing?: number;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this exported this is theoretically breaking, but I guess fine as we should be only using this internally

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I missed this, thanks! While I think removing it would probably be fine, given this is internal metadata, it also doesn't cost us anything to keep it around and mark it as deprecated. We can remove it in v12.

Lms24 and others added 9 commits October 9, 2026 17:39
An unsampled standalone span (e.g. a late INP span) recorded a
`transaction` outcome when it started, although it never becomes a
transaction, and a second `span` outcome when it ended. Record a single
`span` outcome on start instead.

Derive the expected span count in the static sampling integration test
from the `GET /ok` transaction, so it also holds on Bun, which creates
no Express spans.

Co-Authored-By: Claude <noreply@anthropic.com>
Run event processors, `ignoreSpans`, `beforeSendSpan` and
`beforeSendTransaction` on the same transaction and check that every
span is either sent or counted exactly once, both when the transaction
is sent and when `beforeSendTransaction` drops it.

Co-Authored-By: Claude <noreply@anthropic.com>
…ceholder span

When `onlyIfParent` finds no parent, the non-recording placeholder span becomes
active. Spans started inside it were recorded as `sample_rate` drops (and since
span outcomes are now recorded on the static path, also without span streaming).
Give the placeholder a `no_parent_span` drop reason so nested spans inherit it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s` on the static path

Without span streaming, `ignoreSpans` is applied to the transaction event in
`processBeforeSend`. Spans and transactions dropped there were recorded as
`before_send`, while span streaming records `ignored` for the same drop.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…not be sent

Unsampled spans record their outcome when they start, so spans a sampled
transaction would never contain (e.g. unfinished children) are counted too.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Lms24
Lms24 force-pushed the lms/fix-core-span-outcomes branch from b54716b to db09aac Compare October 9, 2026 15:39
Lms24 and others added 2 commits October 9, 2026 17:41
…ent reports

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ingMetadata`

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants