Skip to content

Commit 2dce96d

Browse files
authored
Replace ALWAYS_PARENT with a composite ParentOrElse sampler (open-telemetry#609)
* Split ALWAYS_PARENT based on default behavior if no parent Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> * Rename RootOnly to ParentOrElse Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> * Address feedback Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com> * More feedback Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
1 parent 865a31d commit 2dce96d

1 file changed

Lines changed: 32 additions & 17 deletions

File tree

specification/trace/sdk.md

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,44 @@ Description MUST NOT change over time and caller can cache the returned value.
101101

102102
### Built-in samplers
103103

104-
These are the default samplers implemented in the OpenTelemetry SDK:
105-
106-
* ALWAYS_ON
107-
* This will be used as a default.
108-
* Description MUST be `AlwaysOnSampler`.
109-
* ALWAYS_OFF
110-
* Description MUST be `AlwaysOffSampler`.
111-
* ALWAYS_PARENT
112-
* `Returns RECORD_AND_SAMPLED` if `SampledFlag` is set to true on parent
113-
SpanContext and `NOT_RECORD` otherwise.
114-
* Description MUST be `AlwaysParentSampler`.
115-
* Probability
116-
* The default behavior should be to trust the parent `SampledFlag`. However
104+
#### AlwaysOn
105+
106+
* This is the default sampler.
107+
* Returns `RECORD_AND_SAMPLED` always.
108+
* Description MUST be `AlwaysOnSampler`.
109+
110+
#### AlwaysOff
111+
112+
* Returns `NOT_RECORD` always.
113+
* Description MUST be `AlwaysOffSampler`.
114+
115+
#### Probability
116+
117+
* The default behavior should be to trust the parent `SampledFlag`. However
117118
there should be configuration to change this.
118-
* The default behavior is to apply the sampling probability only for Spans
119+
* The default behavior is to apply the sampling probability only for Spans
119120
that are root spans (no parent) and Spans with remote parent. However there
120121
should be configuration to change this to "root spans only", or "all spans".
121-
* Description MUST be `ProbabilitySampler{0.000100}`.
122-
123-
#### Probability Sampler algorithm
122+
* Description MUST be `ProbabilitySampler{0.000100}`.
124123

125124
TODO: Add details about how the probability sampler is implemented as a function
126125
of the `TraceID`.
126+
TODO: Split out the parent handling.
127+
128+
#### ParentOrElse
129+
130+
* This is a composite sampler. `ParentOrElse(delegateSampler)` either respects the parent span's sampling decision or delegates to `delegateSampler` for root spans.
131+
* If parent exists:
132+
* If parent's `SampledFlag` is set to `true` returns `RECORD_AND_SAMPLED`
133+
* If parent's `SampledFlag` is set to `false` returns `NOT_RECORD`
134+
* If no parent (root span) exists returns the result of the `delegateSampler`.
135+
* Description MUST be `ParentOrElse{delegateSampler.getDescription()}`.
136+
137+
|Parent|`ParentOrElse(delegateSampler)`
138+
|--|--|
139+
|Exists and `SampledFlag` is `true`|`RECORD_AND_SAMPLED`|
140+
|Exists and `SampledFlag` is `false`|`NOT_RECORD`|
141+
|No parent(root spans)|Result of `delegateSampler()`|
127142

128143
## Tracer Creation
129144

0 commit comments

Comments
 (0)