Skip to content

Commit

Permalink
Add ParentNotRemoteOrElse and fix Probability sampler definition
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Aug 19, 2020
1 parent a6dd3a1 commit 0880a0a
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ 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)`.
OpenTelemetry supports a number of built-in samplers to choose from.
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 `SampledFlag`. 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)`
Required parameters:

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

Optional parameters:

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

|Parent|`ParentBase`
|--|--|
|Exists and `SampledFlag` is `true`|`RECORD_AND_SAMPLED`|
|Exists and `SampledFlag` is `false`|`NOT_RECORD`|
|No parent(root spans)|Result of `delegateSampler()`|
|Remote parent and `SampledFlag` is `true`|`RECORD_AND_SAMPLED` or result of `localParentSampled()` if configured|
|Remote parent and `SampledFlag` is `false`|`NOT_RECORD` or result of `localParentNotSampled()` if configured|
|Local parent and `SampledFlag` is `true`|`RECORD_AND_SAMPLED` or result of `remoteParentSampled()` if configured|
|Local parent and `SampledFlag` is `false`|`NOT_RECORD` or result of `localParentNotSampled()` if configured|
|No parent(root spans) or `Remote` parent |Result of `root()`|

## Tracer Creation

Expand Down

0 comments on commit 0880a0a

Please sign in to comment.