Skip to content

feat(core): Emit no_parent_span client outcomes for discarded spans requiring a parent#20350

Open
Lms24 wants to merge 4 commits intodevelopfrom
lms/feat-record-no_parent_span-client-outcome
Open

feat(core): Emit no_parent_span client outcomes for discarded spans requiring a parent#20350
Lms24 wants to merge 4 commits intodevelopfrom
lms/feat-record-no_parent_span-client-outcome

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented Apr 16, 2026

This PR adds reporting a client discard outcome for spans we skip because they require a parent span to be active. This happens when onlyIfParent: true is set when starting spans, or in custom logic for http.client spans. With this PR, we should now get a much clearer picture of how many spans users are missing out on.

In span streaming, we'll always emit them (see #17932) spans.

closes https://linear.app/getsentry/issue/SDK-1123/add-client-report-outcome-for-dropped-spans-because-of-missing-parent

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 16, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.78 kB - -
@sentry/browser - with treeshaking flags 24.27 kB - -
@sentry/browser (incl. Tracing) 43.65 kB +0.09% +39 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 45.36 kB +0.08% +36 B 🔺
@sentry/browser (incl. Tracing, Profiling) 48.56 kB +0.11% +52 B 🔺
@sentry/browser (incl. Tracing, Replay) 82.78 kB +0.05% +40 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 72.29 kB +0.06% +39 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 87.47 kB +0.05% +39 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 99.71 kB +0.05% +40 B 🔺
@sentry/browser (incl. Feedback) 42.59 kB - -
@sentry/browser (incl. sendFeedback) 30.45 kB - -
@sentry/browser (incl. FeedbackAsync) 35.45 kB - -
@sentry/browser (incl. Metrics) 27.07 kB - -
@sentry/browser (incl. Logs) 27.2 kB - -
@sentry/browser (incl. Metrics & Logs) 27.89 kB - -
@sentry/react 27.53 kB - -
@sentry/react (incl. Tracing) 45.92 kB +0.09% +38 B 🔺
@sentry/vue 30.62 kB +0.05% +14 B 🔺
@sentry/vue (incl. Tracing) 45.49 kB +0.1% +42 B 🔺
@sentry/svelte 25.8 kB - -
CDN Bundle 28.46 kB - -
CDN Bundle (incl. Tracing) 44.8 kB +0.25% +110 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 45.89 kB +0.25% +111 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.73 kB - -
CDN Bundle (incl. Tracing, Replay) 81.76 kB +0.14% +113 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 82.84 kB +0.14% +114 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 87.29 kB +0.14% +122 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 88.35 kB +0.14% +119 B 🔺
CDN Bundle - uncompressed 83.12 kB - -
CDN Bundle (incl. Tracing) - uncompressed 133.91 kB +0.21% +270 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 137.32 kB +0.2% +270 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 210.63 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 251.14 kB +0.11% +270 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 254.54 kB +0.11% +270 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 264.05 kB +0.11% +270 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 267.44 kB +0.11% +270 B 🔺
@sentry/nextjs (client) 48.46 kB +0.09% +39 B 🔺
@sentry/sveltekit (client) 44.1 kB +0.1% +40 B 🔺
@sentry/node-core 57.99 kB +0.1% +54 B 🔺
@sentry/node 174.87 kB +0.06% +91 B 🔺
@sentry/node - without tracing 97.94 kB +0.08% +76 B 🔺
@sentry/aws-serverless 115.17 kB +0.06% +60 B 🔺

View base workflow run

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 16, 2026

@Lms24 Lms24 marked this pull request as ready for review April 16, 2026 15:28
@Lms24 Lms24 self-assigned this Apr 16, 2026
@Lms24 Lms24 requested review from chargome, nicohrubec and s1gr1d April 16, 2026 15:34
@s1gr1d s1gr1d self-assigned this Apr 17, 2026
Comment on lines 51 to +56
const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;

if (shouldSkipSpan) {
getClient()?.recordDroppedEvent('no_parent_span', 'span');
}
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.

Maybe this could be made a bit more robust. Right now it's checking shouldSkipSpan but the value of the variable could depend on something else than onlyIfParent in the future. Then this would be wrong.

The test also only check for dropped events and not necessarily that this resulted because of a missing parent span.

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.

Yeah I guess we could inline the variable or name it a bit more precise, unless you had something else in mind?

import { afterAll, describe, expect } from 'vitest';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';

describe('no_parent_span client report (streaming)', () => {
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.

Suggested change
describe('no_parent_span client report (streaming)', () => {
describe('no_parent_span client report', () => {

| 'ignored'
| 'invalid';
| 'invalid'
| 'no_parent_span';
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.

do we need a change in relay for this?

Comment on lines 51 to +56
const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx);
const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx;

if (shouldSkipSpan) {
getClient()?.recordDroppedEvent('no_parent_span', 'span');
}
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.

Yeah I guess we could inline the variable or name it a bit more precise, unless you had something else in mind?

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