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

Specify Span ID creation with sampling (non-recording spans included) #1225

Merged
merged 25 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
77bbb73
Specify Span ID creation with sampling.
Oberon00 Sep 24, 2020
48b76e4
Add CHANGELOG.
Oberon00 Sep 24, 2020
db30eaf
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Sep 24, 2020
57a4e25
Mismerge/lint.
Oberon00 Sep 24, 2020
c59c207
Period.
Oberon00 Sep 24, 2020
e31741a
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Sep 25, 2020
b6afd59
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Oct 6, 2020
d0fbf4e
Update specification/trace/sdk.md
Oberon00 Oct 7, 2020
eceae84
Merge remote-tracking branch 'upstream/master' into sdk-spanid-sampling
Oberon00 Oct 12, 2020
4006816
Ensure that even DROPed spans always have a valid ID.
Oberon00 Oct 12, 2020
08b15ed
Update specification/trace/sdk.md
Oberon00 Oct 22, 2020
bfd652f
Add compliance matrix entry.
Oberon00 Oct 22, 2020
83e0410
Merge remote-tracking branch 'upstream/master' into sdk-spanid-sampling
Oberon00 Oct 22, 2020
6f04106
Fix compliance matrix.
Oberon00 Oct 22, 2020
34263a3
Apply suggestions from code review
Oberon00 Oct 28, 2020
9933136
Fix dead internal link.
Oberon00 Oct 28, 2020
bc9ef43
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Nov 3, 2020
eb989b7
Add forward-ref to ParentBased sampler.
Oberon00 Nov 3, 2020
17a58fb
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Nov 3, 2020
9c9d652
Typo
Oberon00 Nov 3, 2020
24b6032
Merge branch 'master' into sdk-spanid-sampling
Oberon00 Nov 11, 2020
5d8adab
Specify that new Span ids should be always generated.
carlosalberto Nov 13, 2020
a18c6bc
Update CHANGELOG.
carlosalberto Nov 13, 2020
a8af8f3
Update spec-compliance-matrix.md
carlosalberto Nov 13, 2020
6a28b1c
Update specification/trace/sdk.md
carlosalberto Nov 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ Updates:
- SDK: Specify known values, as well as basic error handling for OTEL_PROPAGATORS.
([#962](https://github.com/open-telemetry/opentelemetry-specification/pull/962))
([#995](https://github.com/open-telemetry/opentelemetry-specification/pull/995))
- SDK: Specify when to generate new IDs with sampling
([#1225](https://github.com/open-telemetry/opentelemetry-specification/pull/1225))
- Remove custom header name for Baggage, use official header
([#993](https://github.com/open-telemetry/opentelemetry-specification/pull/993))
- Trace API: Clarifications for `Span.End`, e.g. IsRecording becomes false after End
Expand Down
1 change: 1 addition & 0 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ status of the feature is not known.
|[Sampling](specification/trace/sdk.md#sampling)|
|Allow samplers to modify tracestate | | + | | [-](https://github.com/open-telemetry/opentelemetry-python/issues/1220) | | + | | + | | |
|ShouldSample gets full parent Context | | + | + | + | | + | | | | |
|[New Span ID created also for non-recording Spans](specification/trace/sdk.md#sdk-span-creation) | | | | | | | | | | |

## Baggage

Expand Down
27 changes: 22 additions & 5 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,28 @@ The following table summarizes the expected behavior for each combination of
The SDK defines the interface [`Sampler`](#sampler) as well as a set of
[built-in samplers](#built-in-samplers) and associates a `Sampler` with each [`TracerProvider`].

When asked to create a Span, the SDK MUST query the `Sampler`'s [`ShouldSample`](#shouldsample) method before actually creating the span, and act accordingly:
see description of [`ShouldSample`'s](#shouldsample) return value below for how to set `IsRecording` and `Sampled` on the Span,
and the [table above](#recording-sampled-reaction-table) on whether to pass the `Span` to `SpanProcessor`s.
A non-recording span MAY be implemented using the same mechanism as when a `Span` is created with no API-implementation installed
(sometimes called a `NoOpSpan` or `DefaultSpan`).
### SDK Span creation

When asked to create a Span, the SDK MUST act as if doing the following in order:

1. If there is a valid parent trace ID, use it. Otherwise generate a new trace ID
(note: this must be done before calling `ShouldSample`, because it expects
a valid trace ID as input).
2. Query the `Sampler`'s [`ShouldSample`](#shouldsample) method
(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.
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,
and the [table above](#recording-sampled-reaction-table) on whether
to pass the `Span` to `SpanProcessor`s.
A non-recording span MAY be implemented using the same mechanism as when a
`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).

### Sampler

Expand Down