From e13ef336606669a10fb914159d854eed526a946d Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 18 May 2020 15:43:09 -0700 Subject: [PATCH] Add ParentNotRemoteOrElse and fix Probability sampler definition Signed-off-by: Bogdan Drutu --- specification/trace/sdk.md | 45 +++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/specification/trace/sdk.md b/specification/trace/sdk.md index fdbe645536d..8861fadb4e2 100644 --- a/specification/trace/sdk.md +++ b/specification/trace/sdk.md @@ -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 @@ -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)` +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