Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trace-sdk-sampler] Differentiate between root and child span creation in trace sampling spec #3888

Closed
14 changes: 11 additions & 3 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,13 @@ When asked to create a Span, the SDK MUST act as if doing the following in order
(Note that the [built-in `ParentBasedSampler`](#parentbased) can be used to
use the sampling decision of the parent,
translating a set SampledFlag to RECORD and an unset one to DROP).
3. Generate a new span ID for the `Span`, independently of the sampling decision.
This is done so other components (such as logs or exception handling) can rely on
a unique span ID, even if the `Span` is a non-recording instance.
3. If there isn't currently a span (i.e the span being created will become the
root span), SDKs MUST generate a new span ID for the `Span`, independently of
the sampling decision. This is done so other components (such as logs or
exception handling) can rely on a unique span ID, even if the `Span` is a
non-recording instance. For non-root spans, SDKs MAY skip creation of spans
if `ShouldSample` results in a non-recording instance (`DROP`). This is done
to optimize the performance by avoiding creating a span when unnecessary.
4. Create a span depending on the decision returned by `ShouldSample`:
see description of [`ShouldSample`'s](#shouldsample) return value below
for how to set `IsRecording` and `Sampled` on the Span,
Expand All @@ -307,6 +311,10 @@ When asked to create a Span, the SDK MUST act as if doing the following in order
`Span` is created without an SDK installed or as described in
[wrapping a SpanContext in a Span](api.md#wrapping-a-spancontext-in-a-span).

Note: Once the span creation behavior has shipped in a stable SDK release it
MUST NOT be changed without clear indication of a breaking change being made
(major version bump typically).

### Sampler

`Sampler` interface allows users to create custom samplers which will return a
Expand Down