|
1 | 1 | # Sampling |
2 | 2 |
|
3 | | -This document is about the sampling bit, sampling decision, samplers and how and when does |
4 | | -OpenCensus sample traces. A sampled traces is a traces that gets exported via the configured |
| 3 | +This document is about the sampling bit, sampling decision, samplers and how and when |
| 4 | +OpenCensus samples traces. A sampled trace is one that gets exported via the configured |
5 | 5 | exporters. |
6 | 6 |
|
7 | 7 | ## Sampling Bit (propagated via TraceOptions) |
8 | 8 |
|
9 | | -Sampling bit is always set only at the start of a Span, and is using a `Sampler` |
| 9 | +The Sampling bit is always set only at the start of a Span, using a `Sampler` |
10 | 10 |
|
11 | 11 | ### What kind of samplers does OpenCensus support? |
12 | | -* `AlwaysSample` - sampler that always makes a "yes" decision every time. |
13 | | -* `NeverSample` - sampler that always makes a "no" decision every time. |
| 12 | +* `AlwaysSample` - sampler that makes a "yes" decision every time. |
| 13 | +* `NeverSample` - sampler that makes a "no" decision every time. |
14 | 14 | * `Probability` - sampler that tries to uniformly sample traces with a given probability. When |
15 | | -applied to a child `Span` of a **sampled** parent `Span` then it keeps the sampling decision. |
| 15 | +applied to a child `Span` of a **sampled** parent `Span`, the child `Span` keeps the sampling decision. |
16 | 16 |
|
17 | 17 | ### How can users control the Sampler that is used for sampling? |
18 | | -There are 2 ways to control the `Sampler` used when the library does sampling: |
| 18 | +There are 2 ways to control the `Sampler` used when the library samples: |
19 | 19 | * Controlling the global default `Sampler` via [TraceConfig](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/TraceConfig.md). |
20 | | -* Pass a specific `Sampler` when start the [Span](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/Span.md) |
| 20 | +* Pass a specific `Sampler` when starting the [Span](https://github.com/census-instrumentation/opencensus-specs/blob/master/trace/Span.md) |
21 | 21 | (a.k.a. "span-scoped"). |
22 | 22 | * For example `AlwaysSample` and `NeverSample` can be used to implement request-specific |
23 | 23 | decisions such as those based on http paths. |
24 | 24 |
|
25 | 25 | ### When does OpenCensus sample traces? |
26 | | -The OpenCensus library does sampling based on the following rules: |
27 | | -1. If the span is a root `Span` then a `Sampler` will be used to make the sampling decision: |
| 26 | +The OpenCensus library samples based on the following rules: |
| 27 | +1. If the span is a root `Span`, then a `Sampler` will be used to make the sampling decision: |
28 | 28 | * If a "span-scoped" `Sampler` is provided, use it to determine the sampling decision. |
29 | 29 | * Else use the global default `Sampler` to determine the sampling decision. |
30 | 30 | 2. If the span is a child of a remote `Span` the sampling decision will be: |
31 | 31 | * If a "span-scoped" `Sampler` is provided, use it to determine the sampling decision. |
32 | 32 | * Else use the global default `Sampler` to determine the sampling decision. |
33 | | -2. If the span is a child of a local `Span` the sampling decision will be: |
| 33 | +3. If the span is a child of a local `Span` the sampling decision will be: |
34 | 34 | * If a "span-scoped" `Sampler` is provided, use it to determine the sampling decision. |
35 | | - * Else keep the sampling from the parent. |
| 35 | + * Else keep the sampling decision from the parent. |
0 commit comments