|
1 | 1 | #pragma once |
2 | 2 |
|
| 3 | +// This component provides an `enum class`, `SamplingMechanism`, describing a |
| 4 | +// reason for a sampling decision. A sampler (or a user, with a manual |
| 5 | +// override) decides whether to keep or to drop a trace, but it might do so for |
| 6 | +// various reasons. |
| 7 | +// |
| 8 | +// Some of those reasons are indicated by existing `SamplingPriority` values, |
| 9 | +// but `SamplingPriority` is inadequate for future expansion, for two reasons: |
| 10 | +// |
| 11 | +// - `SamplingPriority` conflates the keep/drop decision with the reason (e.g. |
| 12 | +// `UserKeep` vs. `SamplerKeep`). Some engineers dislike this. |
| 13 | +// - Some tracer implementations do not decode `SamplingPriority` integer values |
| 14 | +// outside of those enumerated in this library. This makes adding new values |
| 15 | +// infeasible, as older versions of tracers propagating the `SamplingPriority` |
| 16 | +// along the trace will omit new integer values. |
| 17 | +// |
| 18 | +// `SamplingMechanism` is a redefinition of the "why" of a sampling decision, |
| 19 | +// while the "what" is still the binary keep/drop. |
| 20 | +// |
| 21 | +// Since `SamplingPriority` is already in use and has implications for sampling |
| 22 | +// behavior (both in its propagation along and trace and its interpretation by |
| 23 | +// the trace agent), the combination `{SamplingPriority, SamplingMechanism}` is |
| 24 | +// used to completely describe a sampling decision. The `SamplingPriority` |
| 25 | +// conveys the keep/drop decision, as well as the existing (and now redundant) |
| 26 | +// user vs. sampler distinction, while the `SamplingMechanism` conveys |
| 27 | +// precisely where the sampling decision came from, e.g. a user-specified |
| 28 | +// sampling rule, a user-specified override, an agent-specified priority |
| 29 | +// sampling rate, etc. |
| 30 | +// |
| 31 | +// To allow forward compatibility with future `SamplingMechanism` values, |
| 32 | +// sampling mechanism is treated as just an integer when being deserialized or |
| 33 | +// serialized. `SamplingMechanism` enumerates integer values relevant to logic |
| 34 | +// within the tracer. |
| 35 | + |
3 | 36 | namespace datadog { |
4 | 37 | namespace tracing { |
5 | 38 |
|
|
0 commit comments