-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathspan_sampler_config.h
61 lines (47 loc) · 1.6 KB
/
span_sampler_config.h
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
#pragma once
// This component provides a `struct`, `SpanSamplerConfig`, used to configure
// `SpanSampler`. `SpanSampler` accepts a `FinalizedSpanSamplerConfig`, which
// must be obtained from a call to `finalize_config`.
//
// `SpanSamplerConfig` is specified as the `span_sampler` property of
// `TracerConfig`.
#include <unordered_map>
#include <vector>
#include "config.h"
#include "expected.h"
#include "logger.h"
#include "optional.h"
#include "rate.h"
#include "span_matcher.h"
namespace datadog {
namespace tracing {
struct SpanSamplerConfig {
struct Rule : public SpanMatcher {
double sample_rate = 1.0;
Optional<double> max_per_second;
Rule(const SpanMatcher&);
Rule() = default;
};
// Can be overriden by the `DD_TRACE_SAMPLING_RULES` environment variable.
// Also, the `DD_TRACE_SAMPLE_RATE` environment variable, if present, causes a
// corresponding `Rule` to be appended to `rules`.
std::vector<Rule> rules;
};
class FinalizedSpanSamplerConfig {
friend Expected<FinalizedSpanSamplerConfig> finalize_config(
const SpanSamplerConfig&, Logger&);
friend class FinalizedTracerConfig;
FinalizedSpanSamplerConfig() = default;
public:
struct Rule : public SpanMatcher {
Rate sample_rate;
Optional<double> max_per_second;
};
std::vector<Rule> rules;
std::unordered_map<ConfigName, ConfigMetadata> metadata;
};
Expected<FinalizedSpanSamplerConfig> finalize_config(const SpanSamplerConfig&,
Logger&);
std::string to_string(const FinalizedSpanSamplerConfig::Rule&);
} // namespace tracing
} // namespace datadog