-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdatadog_agent.h
More file actions
74 lines (58 loc) · 2 KB
/
datadog_agent.h
File metadata and controls
74 lines (58 loc) · 2 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
#pragma once
// This component provides a `class`, `DatadogAgent`, that implements the
// `Collector` interface in terms of periodic HTTP requests to a Datadog Agent.
//
// `DatadogAgent` is configured by `DatadogAgentConfig`. See
// `datadog_agent_config.h`.
#include <datadog/clock.h>
#include <datadog/collector.h>
#include <datadog/event_scheduler.h>
#include <datadog/http_client.h>
#include <datadog/tracer_signature.h>
#include <memory>
#include <mutex>
#include <vector>
#include "remote_config/remote_config.h"
namespace datadog {
namespace tracing {
class FinalizedDatadogAgentConfig;
class Logger;
struct SpanData;
class TraceSampler;
struct TracerSignature;
class DatadogAgent : public Collector {
public:
struct TraceChunk {
std::vector<std::unique_ptr<SpanData>> spans;
std::shared_ptr<TraceSampler> response_handler;
};
private:
std::mutex mutex_;
Clock clock_;
std::shared_ptr<Logger> logger_;
std::vector<TraceChunk> trace_chunks_;
HTTPClient::URL traces_endpoint_;
HTTPClient::URL remote_configuration_endpoint_;
std::shared_ptr<HTTPClient> http_client_;
std::shared_ptr<EventScheduler> event_scheduler_;
std::vector<EventScheduler::Cancel> tasks_;
std::chrono::steady_clock::duration flush_interval_;
std::chrono::steady_clock::duration request_timeout_;
std::chrono::steady_clock::duration shutdown_timeout_;
remote_config::Manager remote_config_;
std::unordered_map<std::string, std::string> headers_;
void flush();
public:
DatadogAgent(const FinalizedDatadogAgentConfig&,
const std::shared_ptr<Logger>&, const TracerSignature& id,
const std::vector<std::shared_ptr<remote_config::Listener>>&
rc_listeners);
~DatadogAgent();
Expected<void> send(
std::vector<std::unique_ptr<SpanData>>&& spans,
const std::shared_ptr<TraceSampler>& response_handler) override;
void get_and_apply_remote_configuration_updates();
std::string config() const override;
};
} // namespace tracing
} // namespace datadog