rippled
Loading...
Searching...
No Matches
CollectorManager.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpld/app/main/CollectorManager.h>
21
22#include <memory>
23
24namespace ripple {
25
27{
28public:
32
34 : m_journal(journal)
35 {
36 std::string const& server = get(params, "server");
37
38 if (server == "statsd")
39 {
40 beast::IP::Endpoint const address(
41 beast::IP::Endpoint::from_string(get(params, "address")));
42 std::string const& prefix(get(params, "prefix"));
43
45 beast::insight::StatsDCollector::New(address, prefix, journal);
46 }
47 else
48 {
50 }
51
53 }
54
56
58 collector() override
59 {
60 return m_collector;
61 }
62
64 group(std::string const& name) override
65 {
66 return m_groups->get(name);
67 }
68};
69
70//------------------------------------------------------------------------------
71
74{
75 return std::make_unique<CollectorManagerImp>(params, journal);
76}
77
78} // namespace ripple
A version-independent IP address and port combination.
Definition IPEndpoint.h:38
static Endpoint from_string(std::string const &s)
A generic endpoint for log messages.
Definition Journal.h:60
virtual Group::ptr const & get(std::string const &name)=0
Find or create a new collector with a given name.
static std::shared_ptr< Collector > New()
static std::shared_ptr< StatsDCollector > New(IP::Endpoint const &address, std::string const &prefix, Journal journal)
Create a StatsD collector.
beast::insight::Collector::ptr const & collector() override
std::unique_ptr< beast::insight::Groups > m_groups
beast::insight::Collector::ptr m_collector
beast::insight::Group::ptr const & group(std::string const &name) override
CollectorManagerImp(Section const &params, beast::Journal journal)
Provides the beast::insight::Collector service.
Holds a collection of configuration values.
Definition BasicConfig.h:45
T is_same_v
std::unique_ptr< Groups > make_Groups(Collector::ptr const &collector)
Create a group container that uses the specified collector.
Definition Groups.cpp:137
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::unique_ptr< CollectorManager > make_CollectorManager(Section const &params, beast::Journal journal)
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.