Skip to content

Commit 852f923

Browse files
committed
document sampling_decision.h
1 parent 2931472 commit 852f923

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/datadog/sampling_decision.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#pragma once
22

3+
// This component provides a `struct`, `SamplingDecision`, that describes a
4+
// keep/drop sampling decision (for either trace sampling or span sampling) and
5+
// contains supporting information about the reason for the decision.
6+
37
#include <optional>
48

59
#include "rate.h"
@@ -9,13 +13,36 @@ namespace datadog {
913
namespace tracing {
1014

1115
struct SamplingDecision {
12-
enum class Origin { EXTRACTED, LOCAL, DELEGATED };
16+
enum class Origin {
17+
// There was already a sampling decision associated with this trace when we
18+
// extracted the local root span from somewhere else (i.e.
19+
// `Tracer::extract_span`).
20+
EXTRACTED,
21+
// We made the sampling decision for this trace/span based on one of
22+
// `TraceSampler`, `SpanSampler`, or
23+
// `TraceSegment::override_sampling_priority`).
24+
LOCAL,
25+
// We made a provisional sampling decision earlier, and later requested that
26+
// another service that we call make the sampling decision instead. That
27+
// service then responded with its own sampling decision, which is this one.
28+
// Note that sampling delegation is not yet implemented.
29+
DELEGATED
30+
};
1331

32+
// See `sampling_priority.h`. Positive values mean "keep," while others mean
33+
// "drop."
1434
int priority;
35+
// See `sampling_mechanism.h`.
1536
std::optional<int> mechanism;
37+
// The sample rate associated with this decision, if any.
1638
std::optional<Rate> configured_rate;
39+
// The effective rate of the limiter consulted in this decision, if any. A
40+
// limiter's effective rate is `num_allowed / num_asked`.
1741
std::optional<Rate> limiter_effective_rate;
42+
// The per-second maximum allowed number of "keeps" configured for the limiter
43+
// consulted in this decision, if any.
1844
std::optional<double> limiter_max_per_second;
45+
// The provenance of this decision.
1946
Origin origin;
2047
};
2148

0 commit comments

Comments
 (0)