-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdatadog_agent_config.h
More file actions
104 lines (91 loc) · 3.89 KB
/
datadog_agent_config.h
File metadata and controls
104 lines (91 loc) · 3.89 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
// This component provides facilities for configuring a `DatadogAgent`.
//
// `struct DatadogAgentConfig` contains fields that are used to configure
// `DatadogAgent`. The configuration must first be finalized before it can be
// used by `DatadogAgent`. The function `finalize_config` produces either an
// error or a `FinalizedDatadogAgentConfig`. The latter can be used by
// `DatadogAgent`.
//
// Typical usage of `DatadogAgentConfig` is implicit as part of `TracerConfig`.
// See `tracer_config.h`.
#include <chrono>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "clock.h"
#include "config.h"
#include "expected.h"
#include "http_client.h"
#include "remote_config/listener.h"
namespace datadog {
namespace tracing {
class EventScheduler;
class Logger;
struct DatadogAgentConfig {
// The `HTTPClient` used to submit traces to the Datadog Agent. If this
// library was built with libcurl (the default), then `http_client` is
// optional: a `Curl` instance will be used if `http_client` is left null.
// If this library was built without libcurl, then `http_client` is required
// not to be null.
std::shared_ptr<HTTPClient> http_client = nullptr;
// The `EventScheduler` used to periodically submit batches of traces to the
// Datadog Agent. If `event_scheduler` is null, then a
// `ThreadedEventScheduler` instance will be used instead.
std::shared_ptr<EventScheduler> event_scheduler = nullptr;
// A list of Remote Configuration listeners.
std::vector<std::shared_ptr<remote_config::Listener>>
remote_configuration_listeners;
// A URL at which the Datadog Agent can be contacted.
// The following formats are supported:
//
// - http://<domain or IP>:<port>
// - http://<domain or IP>
// - http+unix://<path to socket>
// - unix://<path to socket>
//
// The port defaults to 8126 if it is not specified.
Optional<std::string> url;
// How often, in milliseconds, to send batches of traces to the Datadog Agent.
Optional<int> flush_interval_milliseconds;
// Maximum amount of time an HTTP request is allowed to run.
Optional<int> request_timeout_milliseconds;
// Maximum amount of time the process is allowed to wait before shutting down.
Optional<int> shutdown_timeout_milliseconds;
// Enable the capability that allows to remotely configure and change the
// behavior of the tracer.
Optional<bool> remote_configuration_enabled;
// How often, in seconds, to query the Datadog Agent for remote configuration
// updates.
Optional<double> remote_configuration_poll_interval_seconds;
};
class FinalizedDatadogAgentConfig {
friend Expected<FinalizedDatadogAgentConfig> finalize_config(
const DatadogAgentConfig&, const std::shared_ptr<Logger>&, const Clock&);
FinalizedDatadogAgentConfig() = default;
public:
Clock clock;
bool remote_configuration_enabled;
std::shared_ptr<HTTPClient> http_client;
std::shared_ptr<EventScheduler> event_scheduler;
std::vector<std::shared_ptr<remote_config::Listener>>
remote_configuration_listeners;
HTTPClient::URL url;
std::chrono::steady_clock::duration flush_interval;
std::chrono::steady_clock::duration request_timeout;
std::chrono::steady_clock::duration shutdown_timeout;
std::chrono::steady_clock::duration remote_configuration_poll_interval;
std::unordered_map<ConfigName, std::vector<ConfigMetadata>> metadata;
// Origin detection
Optional<std::string> admission_controller_uid;
// Indicate if stats computation should be delegated to the Agent.
// This feature is not supported yet, however, we need to inform the Agent to
// not compute stats when APM Tracing `DD_APM_TRACING_ENABLED` is disabled.
bool stats_computation_enabled;
};
Expected<FinalizedDatadogAgentConfig> finalize_config(
const DatadogAgentConfig& config, const std::shared_ptr<Logger>& logger,
const Clock& clock);
} // namespace tracing
} // namespace datadog