Skip to content

Rework span start and end lifecycle hook emission #21368

Description

@Lms24

Currently, the behaviour for spanStart and spanEnd/afterSpanEnd client hook event emissions is a bit inconsistent across SDKs and span types

Sentry Spans (non-OTel path)

CaseSpan classspanStartspanEndNotes
Sampled rootSentrySpanYesYes (via _onSpanEnded)
Negatively sampled rootSentrySpan (sampled: false)YesYes (via _onSpanEnded)Hooks fire, listeners must guard themselves
Sampled childSentrySpanYesYes (via _onSpanEnded)
Negatively sampled childSentryNonRecordingSpanYesNo (end() is no-op)Unpaired!spanStart fires, spanEnd never does
Ignored spanSentryNonRecordingSpanNo (returns before _startChildSpan)No
onlyIfParent, no parentSentryNonRecordingSpanNo (created before createChildOrRootSpan)No
Tracing disabledSentryNonRecordingSpanNo (hasSpansEnabled() = false)No

OTel Spans

CaseOTel SamplingDecisionReaches processor?spanStartspanEnd
Sampled rootRECORD_AND_SAMPLEDYesYesYes
Negatively sampled rootNOT_RECORDNoNoNo
Sampled childRECORD_AND_SAMPLEDYesYesYes
Negatively sampled childNOT_RECORDNoNoNo
Ignored spanNOT_RECORDNoNoNo

Goals

  • We need to align on the behaviour and at the very least fix the unpaired occurance of the negatively sampled child span scenario
  • We simplify which actor emits the events. Ideally, only the span classes (Sentry) and span processor (OTel) emit the hooks. Though this can be challenging with the cases where we early return for ignored/no_parent_span cases.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

CoreSpansjavascriptPull requests that update javascript code

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions