xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
app
main
CollectorManager.cpp
1
#include <xrpld/app/main/CollectorManager.h>
2
3
#include <xrpl/beast/insight/Collector.h>
4
#include <xrpl/beast/insight/Group.h>
5
#include <xrpl/beast/insight/Groups.h>
6
#include <xrpl/beast/insight/NullCollector.h>
7
#include <xrpl/beast/insight/StatsDCollector.h>
8
#include <xrpl/beast/net/IPEndpoint.h>
9
#include <xrpl/beast/utility/Journal.h>
10
#include <xrpl/config/BasicConfig.h>
11
#include <xrpl/config/Constants.h>
12
13
#include <
memory
>
14
#include <
string
>
15
16
namespace
xrpl
{
17
18
class
CollectorManagerImp
:
public
CollectorManager
19
{
20
public
:
21
// NOLINTBEGIN(readability-identifier-naming)
22
beast::Journal
journal_
;
23
beast::insight::Collector::Ptr
collector_
;
24
std::unique_ptr<beast::insight::Groups>
groups_
;
25
// NOLINTEND(readability-identifier-naming)
26
27
CollectorManagerImp
(
Section
const
& params,
beast::Journal
journal) :
journal_
(journal)
28
{
29
std::string
const
& server =
get
(params,
Keys::kServer
);
30
31
if
(server ==
"statsd"
)
32
{
33
beast::ip::Endpoint
const
address(
34
beast::ip::Endpoint::fromString
(
get
(params,
Keys::kAddress
)));
35
std::string
const
& prefix(
get
(params,
Keys::kPrefix
));
36
37
collector_
=
beast::insight::StatsDCollector::make
(address, prefix, journal);
38
}
39
else
40
{
41
collector_
=
beast::insight::NullCollector::make
();
42
}
43
44
groups_
=
beast::insight::makeGroups
(
collector_
);
45
}
46
47
~CollectorManagerImp
()
override
=
default
;
48
49
beast::insight::Collector::Ptr
const
&
50
collector
()
override
51
{
52
return
collector_
;
53
}
54
55
beast::insight::Group::Ptr
const
&
56
group
(
std::string
const
& name)
override
57
{
58
return
groups_
->get(name);
59
}
60
};
61
62
//------------------------------------------------------------------------------
63
64
std::unique_ptr<CollectorManager>
65
makeCollectorManager
(
Section
const
& params,
beast::Journal
journal)
66
{
67
return
std::make_unique<CollectorManagerImp>
(params, journal);
68
}
69
70
}
// namespace xrpl
std::string
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::insight::Collector::Ptr
std::shared_ptr< Collector > Ptr
Definition
Collector.h:29
beast::insight::Group::Ptr
std::shared_ptr< Group > Ptr
Definition
Group.h:16
beast::insight::NullCollector::make
static std::shared_ptr< Collector > make()
Definition
NullCollector.cpp:146
beast::insight::StatsDCollector::make
static std::shared_ptr< StatsDCollector > make(ip::Endpoint const &address, std::string const &prefix, Journal journal)
Create a StatsD collector.
Definition
StatsDCollector.cpp:710
beast::ip::Endpoint
A version-independent IP address and port combination.
Definition
IPEndpoint.h:24
beast::ip::Endpoint::fromString
static Endpoint fromString(std::string const &s)
Definition
IPEndpoint.cpp:42
xrpl::CollectorManagerImp::CollectorManagerImp
CollectorManagerImp(Section const ¶ms, beast::Journal journal)
Definition
CollectorManager.cpp:27
xrpl::CollectorManagerImp::group
beast::insight::Group::Ptr const & group(std::string const &name) override
Definition
CollectorManager.cpp:56
xrpl::CollectorManagerImp::journal_
beast::Journal journal_
Definition
CollectorManager.cpp:22
xrpl::CollectorManagerImp::collector_
beast::insight::Collector::Ptr collector_
Definition
CollectorManager.cpp:23
xrpl::CollectorManagerImp::~CollectorManagerImp
~CollectorManagerImp() override=default
xrpl::CollectorManagerImp::collector
beast::insight::Collector::Ptr const & collector() override
Definition
CollectorManager.cpp:50
xrpl::CollectorManagerImp::groups_
std::unique_ptr< beast::insight::Groups > groups_
Definition
CollectorManager.cpp:24
xrpl::CollectorManager
Provides the beast::insight::Collector service.
Definition
CollectorManager.h:17
xrpl::Section
Holds a collection of configuration values.
Definition
BasicConfig.h:28
std::make_unique
T make_unique(T... args)
memory
beast::insight::makeGroups
std::unique_ptr< Groups > makeGroups(Collector::Ptr const &collector)
Create a group container that uses the specified collector.
Definition
Groups.cpp:115
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::makeCollectorManager
std::unique_ptr< CollectorManager > makeCollectorManager(Section const ¶ms, beast::Journal journal)
Definition
CollectorManager.cpp:65
xrpl::get
T get(Section const §ion, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
Definition
BasicConfig.h:360
string
xrpl::Keys::kAddress
static constexpr auto kAddress
Definition
Constants.h:85
xrpl::Keys::kPrefix
static constexpr auto kPrefix
Definition
Constants.h:147
xrpl::Keys::kServer
static constexpr auto kServer
Definition
Constants.h:157
std::unique_ptr
Generated by
1.17.0