-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtrace_sampler_config.h
More file actions
64 lines (50 loc) · 1.57 KB
/
trace_sampler_config.h
File metadata and controls
64 lines (50 loc) · 1.57 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
#pragma once
// This component provides a `struct`, `TraceSamplerConfig`, used to configure
// `TraceSampler`. `TraceSampler` accepts a `FinalizedTraceSamplerConfig`, which
// must be obtained from a call to `finalize_config`.
//
// `TraceSamplerConfig` is specified as the `trace_sampler` property of
// `TracerConfig`.
#include <unordered_map>
#include <vector>
#include "config.h"
#include "expected.h"
#include "optional.h"
#include "rate.h"
#include "sampling_mechanism.h"
#include "span_matcher.h"
namespace datadog {
namespace tracing {
struct TraceSamplerRule final {
Rate rate;
SpanMatcher matcher;
SamplingMechanism mechanism;
bool bypass_limiter = false;
};
struct TraceSamplerConfig {
struct Rule : public SpanMatcher {
double sample_rate = 1.0;
Rule(const SpanMatcher&);
Rule() = default;
};
Optional<double> sample_rate;
std::vector<Rule> rules;
Optional<double> max_per_second;
};
class FinalizedTraceSamplerConfig {
friend Expected<FinalizedTraceSamplerConfig> finalize_config(
const TraceSamplerConfig& config);
friend class FinalizedTracerConfig;
FinalizedTraceSamplerConfig() = default;
public:
double max_per_second;
std::vector<TraceSamplerRule> rules;
std::unordered_map<ConfigName, std::vector<ConfigMetadata>> metadata;
public:
/// Returns the trace sampler configuration when APM Tracing is disabled.
static FinalizedTraceSamplerConfig apm_tracing_disabled_config();
};
Expected<FinalizedTraceSamplerConfig> finalize_config(
const TraceSamplerConfig& config);
} // namespace tracing
} // namespace datadog