Skip to main content

How can I ensure my custom span is sampled, even if the parent span is sampled out?

Updated over a month ago

Issue

I have custom spans that I would always like to be sampled (for example queue spans). The parent span such as the network request may be sampled out via the tracesSampleRate

Applies To

  • JavaScript SDK users

Resolution

If the root span is sampled out, then by default all child spans of that root will not send. For custom spans you can override this behavior by passing forceTransaction: true, to your startSpan({}) call.
​

Setting that option to true will cause the custom span to become the new parent/root span when one does exist to ensure that it is sent.

Did this answer your question?