rippled
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 <ripple/app/main/CollectorManager.h>
21 #include <memory>
22 
23 namespace ripple {
24 
26 {
27 public:
31 
32  CollectorManagerImp(Section const& params, beast::Journal journal)
33  : m_journal(journal)
34  {
35  std::string const& server = get(params, "server");
36 
37  if (server == "statsd")
38  {
39  beast::IP::Endpoint const address(
40  beast::IP::Endpoint::from_string(get(params, "address")));
41  std::string const& prefix(get(params, "prefix"));
42 
43  m_collector =
44  beast::insight::StatsDCollector::New(address, prefix, journal);
45  }
46  else
47  {
49  }
50 
52  }
53 
54  ~CollectorManagerImp() = default;
55 
57  collector() override
58  {
59  return m_collector;
60  }
61 
63  group(std::string const& name) override
64  {
65  return m_groups->get(name);
66  }
67 };
68 
69 //------------------------------------------------------------------------------
70 
73 {
74  return std::make_unique<CollectorManagerImp>(params, journal);
75 }
76 
77 } // namespace ripple
ripple::Section
Holds a collection of configuration values.
Definition: BasicConfig.h:42
ripple::CollectorManagerImp::~CollectorManagerImp
~CollectorManagerImp()=default
std::string
STL class.
std::shared_ptr< Collector >
ripple::CollectorManagerImp::CollectorManagerImp
CollectorManagerImp(Section const &params, beast::Journal journal)
Definition: CollectorManager.cpp:32
ripple::CollectorManager
Provides the beast::insight::Collector service.
Definition: CollectorManager.h:29
ripple::make_CollectorManager
std::unique_ptr< CollectorManager > make_CollectorManager(Section const &params, beast::Journal journal)
Definition: CollectorManager.cpp:72
ripple::CollectorManagerImp::collector
beast::insight::Collector::ptr const & collector() override
Definition: CollectorManager.cpp:57
beast::insight::StatsDCollector::New
static std::shared_ptr< StatsDCollector > New(IP::Endpoint const &address, std::string const &prefix, Journal journal)
Create a StatsD collector.
Definition: StatsDCollector.cpp:736
beast::insight::Groups::get
virtual Group::ptr const & get(std::string const &name)=0
Find or create a new collector with a given name.
ripple::CollectorManagerImp::m_groups
std::unique_ptr< beast::insight::Groups > m_groups
Definition: CollectorManager.cpp:30
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
beast::insight::make_Groups
std::unique_ptr< Groups > make_Groups(Collector::ptr const &collector)
Create a group container that uses the specified collector.
Definition: Groups.cpp:127
memory
ripple::CollectorManagerImp::group
beast::insight::Group::ptr const & group(std::string const &name) override
Definition: CollectorManager.cpp:63
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::CollectorManagerImp::m_journal
beast::Journal m_journal
Definition: CollectorManager.cpp:28
beast::IP::Endpoint::from_string
static Endpoint from_string(std::string const &s)
Definition: IPEndpoint.cpp:49
ripple::CollectorManagerImp::m_collector
beast::insight::Collector::ptr m_collector
Definition: CollectorManager.cpp:29
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
std::unique_ptr< beast::insight::Groups >
beast::insight::NullCollector::New
static std::shared_ptr< Collector > New()
Definition: NullCollector.cpp:152
ripple::CollectorManagerImp
Definition: CollectorManager.cpp:25
ripple::get
T & get(EitherAmount &amt)
Definition: AmountSpec.h:118