-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathCollectorManager.cpp
More file actions
70 lines (55 loc) · 1.88 KB
/
Copy pathCollectorManager.cpp
File metadata and controls
70 lines (55 loc) · 1.88 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
#include <xrpl/core/CollectorManager.h>
#include <xrpl/basics/BasicConfig.h>
#include <xrpl/beast/insight/Collector.h>
#include <xrpl/beast/insight/Group.h>
#include <xrpl/beast/insight/Groups.h>
#include <xrpl/beast/insight/NullCollector.h>
#include <xrpl/beast/insight/StatsDCollector.h>
#include <xrpl/beast/net/IPEndpoint.h>
#include <xrpl/beast/utility/Journal.h>
#include <memory>
#include <string>
namespace xrpl {
class CollectorManagerImp : public CollectorManager
{
public:
// NOLINTBEGIN(readability-identifier-naming)
beast::Journal journal_;
beast::insight::Collector::ptr collector_;
std::unique_ptr<beast::insight::Groups> groups_;
// NOLINTEND(readability-identifier-naming)
CollectorManagerImp(Section const& params, beast::Journal journal) : journal_(journal)
{
std::string const& server = get(params, "server");
if (server == "statsd")
{
beast::IP::Endpoint const address(
beast::IP::Endpoint::fromString(get(params, "address")));
std::string const& prefix(get(params, "prefix"));
collector_ = beast::insight::StatsDCollector::make(address, prefix, journal);
}
else
{
collector_ = beast::insight::NullCollector::make();
}
groups_ = beast::insight::makeGroups(collector_);
}
~CollectorManagerImp() override = default;
beast::insight::Collector::ptr const&
collector() override
{
return collector_;
}
beast::insight::Group::ptr const&
group(std::string const& name) override
{
return groups_->get(name);
}
};
//------------------------------------------------------------------------------
std::unique_ptr<CollectorManager>
makeCollectorManager(Section const& params, beast::Journal journal)
{
return std::make_unique<CollectorManagerImp>(params, journal);
}
} // namespace xrpl