-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathsampling_mechanism.h
More file actions
71 lines (67 loc) · 2.99 KB
/
sampling_mechanism.h
File metadata and controls
71 lines (67 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
// This component provides an `enum class`, `SamplingMechanism`, describing a
// reason for a sampling decision. A sampler (or a user, with a manual
// override) decides whether to keep or to drop a trace, but it might do so for
// various reasons.
//
// Some of those reasons are indicated by existing `SamplingPriority` values,
// but `SamplingPriority` is inadequate for future expansion, for two reasons:
//
// - `SamplingPriority` conflates the keep/drop decision with the reason (e.g.
// `UserKeep` vs. `SamplerKeep`). Some engineers dislike this.
// - Some tracer implementations do not decode `SamplingPriority` integer values
// outside of those enumerated in this library. This makes adding new values
// infeasible, as older versions of tracers propagating the `SamplingPriority`
// along the trace will omit new integer values.
//
// `SamplingMechanism` is a redefinition of the "why" of a sampling decision,
// while the "what" is still the binary keep/drop.
//
// Since `SamplingPriority` is already in use and has implications for sampling
// behavior (both in its propagation along and trace and its interpretation by
// the trace agent), the combination `{SamplingPriority, SamplingMechanism}` is
// used to completely describe a sampling decision. The `SamplingPriority`
// conveys the keep/drop decision, as well as the existing (and now redundant)
// user vs. sampler distinction, while the `SamplingMechanism` conveys
// precisely where the sampling decision came from, e.g. a user-specified
// sampling rule, a user-specified override, an agent-specified priority
// sampling rate, etc.
//
// To allow forward compatibility with future `SamplingMechanism` values,
// sampling mechanism is treated as just an integer when being deserialized or
// serialized. `SamplingMechanism` enumerates integer values relevant to logic
// within the tracer.
namespace datadog {
namespace tracing {
enum class SamplingMechanism {
// There are no sampling rules configured, and the tracer has not yet
// received any rates from the agent.
DEFAULT = 0,
// The sampling decision was due to a sampling rate conveyed by the agent.
AGENT_RATE = 1,
// Reserved for future use.
REMOTE_RATE_AUTO = 2,
// The sampling decision was due to a matching user-specified sampling rule.
RULE = 3,
// The sampling decision was made explicitly by the user, who set a sampling
// priority.
MANUAL = 4,
// Trace was kept because of AppSec event.
APP_SEC = 5,
// Reserved for future use.
REMOTE_RATE_USER_DEFINED = 6,
// Reserved for future use.
REMOTE_RATE_EMERGENCY = 7,
// Individual span kept by a matching span sampling rule when the enclosing
// trace was dropped.
SPAN_RULE = 8,
// Reserved for future use.
OTLP_RULE = 9,
// Sampling rule configured by user via remote configuration.
REMOTE_RULE = 11,
// Adaptive sampling rule automatically computed by Datadog backend and sent
// via remote configuration.
REMOTE_ADAPTIVE_RULE = 12,
};
} // namespace tracing
} // namespace datadog