Skip to content

Commit

Permalink
Add ParentNotRemoteOrElse and fix Probability sampler definition (#610)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Co-authored-by: Carlos Alberto Cortez <calberto.cortez@gmail.com>
  • Loading branch information
bogdandrutu and carlosalberto authored Aug 21, 2020
1 parent 376e5f4 commit f089eba
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 @@ -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:

* `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

0 comments on commit f089eba

Please sign in to comment.