feat(core): Emit no_parent_span client outcomes for discarded spans requiring a parent#20350
feat(core): Emit no_parent_span client outcomes for discarded spans requiring a parent#20350
no_parent_span client outcomes for discarded spans requiring a parent#20350Conversation
… requiring a parent
size-limit report 📦
|
| const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx); | ||
| const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx; | ||
|
|
||
| if (shouldSkipSpan) { | ||
| getClient()?.recordDroppedEvent('no_parent_span', 'span'); | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)', () => { |
There was a problem hiding this comment.
| describe('no_parent_span client report (streaming)', () => { | |
| describe('no_parent_span client report', () => { |
| | 'ignored' | ||
| | 'invalid'; | ||
| | 'invalid' | ||
| | 'no_parent_span'; |
There was a problem hiding this comment.
do we need a change in relay for this?
| const shouldSkipSpan = options.onlyIfParent && !trace.getSpan(activeCtx); | ||
| const ctx = shouldSkipSpan ? suppressTracing(activeCtx) : activeCtx; | ||
|
|
||
| if (shouldSkipSpan) { | ||
| getClient()?.recordDroppedEvent('no_parent_span', 'span'); | ||
| } |
There was a problem hiding this comment.
Yeah I guess we could inline the variable or name it a bit more precise, unless you had something else in mind?
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: trueis set when starting spans, or in custom logic forhttp.clientspans. 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