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

Rename ParentOrElse to ParentBased and generalize to support all cases #610

Merged
merged 4 commits into from
Aug 21, 2020
Merged
Changes from 1 commit
Commits
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
45 changes: 30 additions & 15 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Description MUST NOT change over time and caller can cache the returned value.
### Built-in samplers

OpenTelemetry supports a number of built-in samplers to choose from.
The default sampler is `ParentOrElse(AlwaysOn)`.
The default sampler is `ParentBased(root=AlwaysOn)`.

#### AlwaysOn

Expand All @@ -111,27 +111,42 @@ The default sampler is `ParentOrElse(AlwaysOn)`.

#### Probability

* The `ProbabilitySampler` MUST ignore the parent `SampledFlag`.
To respect the parent `SampledFlag`, the `ProbabilitySampler` should be used as a delegate of the `ParentOrElse` sampler specified below.
* The `ProbabilitySampler` MUST ignore the parent. To respect the parent
`SampledFlag`, the `ProbabilitySampler` should be used as a delegate of the
`ParentBased` sampler specified below.
* Description MUST be `ProbabilitySampler{0.000100}`.

TODO: Add details about how the `ProbabilitySampler` is implemented as a function
of the `TraceID`.

#### ParentOrElse
#### ParentBased

* This is a composite sampler. `ParentOrElse(delegateSampler)` either respects the parent span's sampling decision or delegates to `delegateSampler` for root spans.
* If parent exists:
* If parent's `SampledFlag` is set to `true` returns `RECORD_AND_SAMPLED`
* If parent's `SampledFlag` is set to `false` returns `NOT_RECORD`
* If no parent (root span) exists returns the result of the `delegateSampler`.
* Description MUST be `ParentOrElse{delegateSampler.getDescription()}`.
* This is a composite sampler. `ParentBased` helps distinguished between the
following cases:
* No parent (root span).
* Remote parent (`SpanContext.IsRemote() == true`) with `SampledFlag` equals `true`
* Remote parent (`SpanContext.IsRemote() == true`) with `SampledFlag` equals `false`
* Local parent (`SpanContext.IsRemote() == false`) with `SampledFlag` equals `true`
* Local parent (`SpanContext.IsRemote() == false`) with `SampledFlag` equals `false`

|Parent|`ParentOrElse(delegateSampler)`
|--|--|
|Exists and `SampledFlag` is `true`|`RECORD_AND_SAMPLED`|
|Exists and `SampledFlag` is `false`|`NOT_RECORD`|
|No parent(root spans)|Result of `delegateSampler()`|
Required parameters:

* `root(Sampler)` - Sampler called for spans with no parent (root spans)

Optional parameters:
bogdandrutu marked this conversation as resolved.
Show resolved Hide resolved

* `remoteParentSampled(Sampler)` (default: AlwaysOn)
* `remoteParentNotSampled(Sampler)` (default: AlwaysOff)
* `localParentSampled(Sampler)` (default: AlwaysOn)
* `localParentNotSampled(Sampler)` (default: AlwaysOff)

|Parent| parent.isRemote() | parent.IsSampled()| Invoke sampler|
|--|--|--|--|
|absent| n/a | n/a |`root()`|
|present|true|true|`remoteParentSampled()`|
|present|true|false|`remoteParentNotSampled()`|
|present|false|true|`localParentSampled()`|
|present|false|false|`localParentNotSampled()`|

## Tracer Creation

Expand Down