rippled
Public Types | Public Member Functions | Static Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | List of all members
beast::insight::detail::StatsDCollectorImp Class Reference
Inheritance diagram for beast::insight::detail::StatsDCollectorImp:
Inheritance graph
[legend]
Collaboration diagram for beast::insight::detail::StatsDCollectorImp:
Collaboration graph
[legend]

Public Types

using ptr = std::shared_ptr< Collector >
 

Public Member Functions

 StatsDCollectorImp (IP::Endpoint const &address, std::string const &prefix, Journal journal)
 
 ~StatsDCollectorImp () override
 
Hook make_hook (HookImpl::HandlerType const &handler) override
 
Counter make_counter (std::string const &name) override
 Create a counter with the specified name. More...
 
Event make_event (std::string const &name) override
 Create an event with the specified name. More...
 
Gauge make_gauge (std::string const &name) override
 Create a gauge with the specified name. More...
 
Meter make_meter (std::string const &name) override
 Create a meter with the specified name. More...
 
void add (StatsDMetricBase &metric)
 
void remove (StatsDMetricBase &metric)
 
boost::asio::io_service & get_io_service ()
 
std::string const & prefix () const
 
void do_post_buffer (std::string const &buffer)
 
void post_buffer (std::string &&buffer)
 
void on_send (std::shared_ptr< std::deque< std::string >>, boost::system::error_code ec, std::size_t)
 
void log (std::vector< boost::asio::const_buffer > const &buffers)
 
void send_buffers ()
 
void set_timer ()
 
void on_timer (boost::system::error_code ec)
 
void run ()
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 
template<class Handler >
Hook make_hook (Handler handler)
 Create a hook. More...
 
Counter make_counter (std::string const &prefix, std::string const &name)
 
Event make_event (std::string const &prefix, std::string const &name)
 
Gauge make_gauge (std::string const &prefix, std::string const &name)
 
Meter make_meter (std::string const &prefix, std::string const &name)
 
template<class Handler >
Hook make_hook (Handler handler)
 Create a hook. More...
 
Counter make_counter (std::string const &prefix, std::string const &name)
 
Event make_event (std::string const &prefix, std::string const &name)
 
Gauge make_gauge (std::string const &prefix, std::string const &name)
 
Meter make_meter (std::string const &prefix, std::string const &name)
 
template<class Handler >
Hook make_hook (Handler handler)
 Create a hook. More...
 
Counter make_counter (std::string const &prefix, std::string const &name)
 
Event make_event (std::string const &prefix, std::string const &name)
 
Gauge make_gauge (std::string const &prefix, std::string const &name)
 
Meter make_meter (std::string const &prefix, std::string const &name)
 

Static Public Member Functions

static std::shared_ptr< StatsDCollectorNew (IP::Endpoint const &address, std::string const &prefix, Journal journal)
 Create a StatsD collector. More...
 

Private Types

enum  { max_packet_size = 1472 }
 

Static Private Member Functions

static boost::asio::ip::udp::endpoint to_endpoint (IP::Endpoint const &ep)
 

Private Attributes

Journal m_journal
 
IP::Endpoint m_address
 
std::string m_prefix
 
boost::asio::io_service m_io_service
 
std::optional< boost::asio::io_service::work > m_work
 
boost::asio::io_service::strand m_strand
 
boost::asio::basic_waitable_timer< std::chrono::steady_clockm_timer
 
boost::asio::ip::udp::socket m_socket
 
std::deque< std::stringm_data
 
std::recursive_mutex metricsLock_
 
List< StatsDMetricBasemetrics_
 
std::thread m_thread
 

Detailed Description

Definition at line 213 of file StatsDCollector.cpp.

Member Typedef Documentation

◆ ptr

Definition at line 47 of file Collector.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
max_packet_size 

Definition at line 218 of file StatsDCollector.cpp.

Constructor & Destructor Documentation

◆ StatsDCollectorImp()

beast::insight::detail::StatsDCollectorImp::StatsDCollectorImp ( IP::Endpoint const &  address,
std::string const &  prefix,
Journal  journal 
)

Definition at line 245 of file StatsDCollector.cpp.

◆ ~StatsDCollectorImp()

beast::insight::detail::StatsDCollectorImp::~StatsDCollectorImp ( )
override

Definition at line 260 of file StatsDCollector.cpp.

Member Function Documentation

◆ to_endpoint()

static boost::asio::ip::udp::endpoint beast::insight::detail::StatsDCollectorImp::to_endpoint ( IP::Endpoint const &  ep)
staticprivate

Definition at line 239 of file StatsDCollector.cpp.

◆ make_hook() [1/2]

Hook beast::insight::detail::StatsDCollectorImp::make_hook ( HookImpl::HandlerType const &  handler)
overridevirtual

Implements beast::insight::Collector.

Definition at line 270 of file StatsDCollector.cpp.

◆ make_counter() [1/2]

Counter beast::insight::detail::StatsDCollectorImp::make_counter ( std::string const &  name)
overridevirtual

Create a counter with the specified name.

See also
Counter

Implements beast::insight::Collector.

Definition at line 277 of file StatsDCollector.cpp.

◆ make_event() [1/2]

Event beast::insight::detail::StatsDCollectorImp::make_event ( std::string const &  name)
overridevirtual

Create an event with the specified name.

See also
Event

Implements beast::insight::Collector.

Definition at line 284 of file StatsDCollector.cpp.

◆ make_gauge() [1/2]

Gauge beast::insight::detail::StatsDCollectorImp::make_gauge ( std::string const &  name)
overridevirtual

Create a gauge with the specified name.

See also
Gauge

Implements beast::insight::Collector.

Definition at line 291 of file StatsDCollector.cpp.

◆ make_meter() [1/2]

Meter beast::insight::detail::StatsDCollectorImp::make_meter ( std::string const &  name)
overridevirtual

Create a meter with the specified name.

See also
Meter

Implements beast::insight::Collector.

Definition at line 298 of file StatsDCollector.cpp.

◆ add()

void beast::insight::detail::StatsDCollectorImp::add ( StatsDMetricBase metric)

Definition at line 307 of file StatsDCollector.cpp.

◆ remove()

void beast::insight::detail::StatsDCollectorImp::remove ( StatsDMetricBase metric)

Definition at line 314 of file StatsDCollector.cpp.

◆ get_io_service()

boost::asio::io_service& beast::insight::detail::StatsDCollectorImp::get_io_service ( )

Definition at line 323 of file StatsDCollector.cpp.

◆ prefix()

std::string const& beast::insight::detail::StatsDCollectorImp::prefix ( ) const

Definition at line 329 of file StatsDCollector.cpp.

◆ do_post_buffer()

void beast::insight::detail::StatsDCollectorImp::do_post_buffer ( std::string const &  buffer)

Definition at line 335 of file StatsDCollector.cpp.

◆ post_buffer()

void beast::insight::detail::StatsDCollectorImp::post_buffer ( std::string &&  buffer)

Definition at line 341 of file StatsDCollector.cpp.

◆ on_send()

void beast::insight::detail::StatsDCollectorImp::on_send ( std::shared_ptr< std::deque< std::string >>  ,
boost::system::error_code  ec,
std::size_t   
)

Definition at line 350 of file StatsDCollector.cpp.

◆ log()

void beast::insight::detail::StatsDCollectorImp::log ( std::vector< boost::asio::const_buffer > const &  buffers)

Definition at line 367 of file StatsDCollector.cpp.

◆ send_buffers()

void beast::insight::detail::StatsDCollectorImp::send_buffers ( )

Definition at line 384 of file StatsDCollector.cpp.

◆ set_timer()

void beast::insight::detail::StatsDCollectorImp::set_timer ( )

Definition at line 438 of file StatsDCollector.cpp.

◆ on_timer()

void beast::insight::detail::StatsDCollectorImp::on_timer ( boost::system::error_code  ec)

Definition at line 447 of file StatsDCollector.cpp.

◆ run()

void beast::insight::detail::StatsDCollectorImp::run ( )

Definition at line 470 of file StatsDCollector.cpp.

◆ New()

std::shared_ptr< StatsDCollector > beast::insight::StatsDCollector::New ( IP::Endpoint const &  address,
std::string const &  prefix,
Journal  journal 
)
staticinherited

Create a StatsD collector.

Parameters
addressThe IP address and port of the StatsD server.
prefixA string pre-pended before each metric name.
journalDestination for logging output.

Definition at line 736 of file StatsDCollector.cpp.

◆ make_hook() [2/2]

template<class Handler >
Hook beast::insight::Collector::make_hook ( Handler  handler)
inherited

Create a hook.

A hook is called at each collection interval, on an implementation defined thread. This is a convenience facility for gathering metrics in the polling style. The typical usage is to update all the metrics of interest in the handler.

Handler will be called with this signature: void handler (void)

See also
Hook

Definition at line 66 of file Collector.h.

◆ make_counter() [2/2]

Counter beast::insight::Collector::make_counter ( std::string const &  prefix,
std::string const &  name 
)
inherited

Definition at line 83 of file Collector.h.

◆ make_event() [2/2]

Event beast::insight::Collector::make_event ( std::string const &  prefix,
std::string const &  name 
)
inherited

Definition at line 99 of file Collector.h.

◆ make_gauge() [2/2]

Gauge beast::insight::Collector::make_gauge ( std::string const &  prefix,
std::string const &  name 
)
inherited

Definition at line 115 of file Collector.h.

◆ make_meter() [2/2]

Meter beast::insight::Collector::make_meter ( std::string const &  prefix,
std::string const &  name 
)
inherited

Definition at line 131 of file Collector.h.

Member Data Documentation

◆ m_journal

Journal beast::insight::detail::StatsDCollectorImp::m_journal
private

Definition at line 223 of file StatsDCollector.cpp.

◆ m_address

IP::Endpoint beast::insight::detail::StatsDCollectorImp::m_address
private

Definition at line 224 of file StatsDCollector.cpp.

◆ m_prefix

std::string beast::insight::detail::StatsDCollectorImp::m_prefix
private

Definition at line 225 of file StatsDCollector.cpp.

◆ m_io_service

boost::asio::io_service beast::insight::detail::StatsDCollectorImp::m_io_service
private

Definition at line 226 of file StatsDCollector.cpp.

◆ m_work

std::optional<boost::asio::io_service::work> beast::insight::detail::StatsDCollectorImp::m_work
private

Definition at line 227 of file StatsDCollector.cpp.

◆ m_strand

boost::asio::io_service::strand beast::insight::detail::StatsDCollectorImp::m_strand
private

Definition at line 228 of file StatsDCollector.cpp.

◆ m_timer

boost::asio::basic_waitable_timer<std::chrono::steady_clock> beast::insight::detail::StatsDCollectorImp::m_timer
private

Definition at line 229 of file StatsDCollector.cpp.

◆ m_socket

boost::asio::ip::udp::socket beast::insight::detail::StatsDCollectorImp::m_socket
private

Definition at line 230 of file StatsDCollector.cpp.

◆ m_data

std::deque<std::string> beast::insight::detail::StatsDCollectorImp::m_data
private

Definition at line 231 of file StatsDCollector.cpp.

◆ metricsLock_

std::recursive_mutex beast::insight::detail::StatsDCollectorImp::metricsLock_
private

Definition at line 232 of file StatsDCollector.cpp.

◆ metrics_

List<StatsDMetricBase> beast::insight::detail::StatsDCollectorImp::metrics_
private

Definition at line 233 of file StatsDCollector.cpp.

◆ m_thread

std::thread beast::insight::detail::StatsDCollectorImp::m_thread
private

Definition at line 236 of file StatsDCollector.cpp.