xrpld
Loading...
Searching...
No Matches
beast::insight::detail::StatsDCollectorImp Class Reference
Inheritance diagram for beast::insight::detail::StatsDCollectorImp:
Collaboration diagram for beast::insight::detail::StatsDCollectorImp:

Public Types

using ptr = std::shared_ptr<Collector>

Public Member Functions

 StatsDCollectorImp (IP::Endpoint address, std::string prefix, Journal journal)
 ~StatsDCollectorImp () override
Hook makeHook (HookImpl::HandlerType const &handler) override
Counter makeCounter (std::string const &name) override
 Create a counter with the specified name.
Event makeEvent (std::string const &name) override
 Create an event with the specified name.
Gauge makeGauge (std::string const &name) override
 Create a gauge with the specified name.
Meter makeMeter (std::string const &name) override
 Create a meter with the specified name.
void add (StatsDMetricBase &metric)
void remove (StatsDMetricBase &metric)
boost::asio::io_context & getIoContext ()
std::string const & prefix () const
void doPostBuffer (std::string const &buffer)
void postBuffer (std::string &&buffer)
void onSend (std::shared_ptr< std::deque< std::string > >, boost::system::error_code ec, std::size_t)
void sendBuffers ()
void setTimer ()
void onTimer (boost::system::error_code ec)
void run ()
shared_from_this (T... args)
weak_from_this (T... args)
template<class Handler>
Hook makeHook (Handler handler)
 Create a hook.
Counter makeCounter (std::string const &prefix, std::string const &name)
Event makeEvent (std::string const &prefix, std::string const &name)
Gauge makeGauge (std::string const &prefix, std::string const &name)
Meter makeMeter (std::string const &prefix, std::string const &name)

Static Public Member Functions

static void log (std::vector< boost::asio::const_buffer > const &buffers)
static std::shared_ptr< StatsDCollectormake (IP::Endpoint const &address, std::string const &prefix, Journal journal)
 Create a StatsD collector.

Static Private Member Functions

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

Private Attributes

Journal journal_
IP::Endpoint address_
std::string prefix_
boost::asio::io_context ioContext_
std::optional< boost::asio::executor_work_guard< boost::asio::io_context::executor_type > > work_
boost::asio::strand< boost::asio::io_context::executor_type > strand_
boost::asio::basic_waitable_timer< std::chrono::steady_clocktimer_
boost::asio::ip::udp::socket socket_
std::deque< std::stringdata_
std::recursive_mutex metricsLock_
List< StatsDMetricBasemetrics_
std::thread thread_

Static Private Attributes

static constexpr auto kMaxPacketSize = 1472

Detailed Description

Definition at line 203 of file StatsDCollector.cpp.

Member Typedef Documentation

◆ ptr

Definition at line 26 of file Collector.h.

Constructor & Destructor Documentation

◆ StatsDCollectorImp()

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

Definition at line 231 of file StatsDCollector.cpp.

◆ ~StatsDCollectorImp()

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

Definition at line 243 of file StatsDCollector.cpp.

Member Function Documentation

◆ toEndpoint()

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

Definition at line 225 of file StatsDCollector.cpp.

◆ makeHook() [1/2]

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

Implements beast::insight::Collector.

Definition at line 259 of file StatsDCollector.cpp.

◆ makeCounter() [1/2]

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

Create a counter with the specified name.

See also
Counter

Implements beast::insight::Collector.

Definition at line 265 of file StatsDCollector.cpp.

◆ makeEvent() [1/2]

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

Create an event with the specified name.

See also
Event

Implements beast::insight::Collector.

Definition at line 271 of file StatsDCollector.cpp.

◆ makeGauge() [1/2]

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

Create a gauge with the specified name.

See also
Gauge

Implements beast::insight::Collector.

Definition at line 277 of file StatsDCollector.cpp.

◆ makeMeter() [1/2]

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

Create a meter with the specified name.

See also
Meter

Implements beast::insight::Collector.

Definition at line 283 of file StatsDCollector.cpp.

◆ add()

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

Definition at line 291 of file StatsDCollector.cpp.

◆ remove()

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

Definition at line 298 of file StatsDCollector.cpp.

◆ getIoContext()

boost::asio::io_context & beast::insight::detail::StatsDCollectorImp::getIoContext ( )

Definition at line 307 of file StatsDCollector.cpp.

◆ prefix()

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

Definition at line 313 of file StatsDCollector.cpp.

◆ doPostBuffer()

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

Definition at line 319 of file StatsDCollector.cpp.

◆ postBuffer()

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

Definition at line 325 of file StatsDCollector.cpp.

◆ onSend()

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

Definition at line 336 of file StatsDCollector.cpp.

◆ log()

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

Definition at line 353 of file StatsDCollector.cpp.

◆ sendBuffers()

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

Definition at line 368 of file StatsDCollector.cpp.

◆ setTimer()

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

Definition at line 424 of file StatsDCollector.cpp.

◆ onTimer()

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

Definition at line 432 of file StatsDCollector.cpp.

◆ run()

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

Definition at line 455 of file StatsDCollector.cpp.

◆ make()

std::shared_ptr< StatsDCollector > beast::insight::StatsDCollector::make ( 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 719 of file StatsDCollector.cpp.

◆ makeHook() [2/2]

template<class Handler>
Hook beast::insight::Collector::makeHook ( 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 45 of file Collector.h.

◆ makeCounter() [2/2]

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

Definition at line 62 of file Collector.h.

◆ makeEvent() [2/2]

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

Definition at line 78 of file Collector.h.

◆ makeGauge() [2/2]

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

Definition at line 94 of file Collector.h.

◆ makeMeter() [2/2]

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

Definition at line 110 of file Collector.h.

Member Data Documentation

◆ kMaxPacketSize

auto beast::insight::detail::StatsDCollectorImp::kMaxPacketSize = 1472
staticconstexprprivate

Definition at line 207 of file StatsDCollector.cpp.

◆ journal_

Journal beast::insight::detail::StatsDCollectorImp::journal_
private

Definition at line 209 of file StatsDCollector.cpp.

◆ address_

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

Definition at line 210 of file StatsDCollector.cpp.

◆ prefix_

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

Definition at line 211 of file StatsDCollector.cpp.

◆ ioContext_

boost::asio::io_context beast::insight::detail::StatsDCollectorImp::ioContext_
private

Definition at line 212 of file StatsDCollector.cpp.

◆ work_

std::optional<boost::asio::executor_work_guard<boost::asio::io_context::executor_type> > beast::insight::detail::StatsDCollectorImp::work_
private

Definition at line 213 of file StatsDCollector.cpp.

◆ strand_

boost::asio::strand<boost::asio::io_context::executor_type> beast::insight::detail::StatsDCollectorImp::strand_
private

Definition at line 214 of file StatsDCollector.cpp.

◆ timer_

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

Definition at line 215 of file StatsDCollector.cpp.

◆ socket_

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

Definition at line 216 of file StatsDCollector.cpp.

◆ data_

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

Definition at line 217 of file StatsDCollector.cpp.

◆ metricsLock_

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

Definition at line 218 of file StatsDCollector.cpp.

◆ metrics_

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

Definition at line 219 of file StatsDCollector.cpp.

◆ thread_

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

Definition at line 222 of file StatsDCollector.cpp.