TrinityCore
Loading...
Searching...
No Matches
Metric Class Reference

#include <Metric.h>

Public Member Functions

 Metric ()
 
 ~Metric ()
 
 Metric (Metric const &)=delete
 
 Metric (Metric &&)=delete
 
Metricoperator= (Metric const &)=delete
 
Metricoperator= (Metric &&)=delete
 
void Initialize (std::string const &realmName, Trinity::Asio::IoContext &ioContext, std::function< void()> overallStatusLogger)
 
void LoadFromConfigs ()
 
void Update ()
 
bool ShouldLog (std::string_view category, int64 value) const
 
template<class T , class... TagsList>
void LogValue (std::string_view category, T value, TagsList &&... tags) noexcept
 
void LogEvent (std::string_view category, std::string_view title, std::string description)
 
void Unload ()
 
bool IsEnabled () const
 

Static Public Member Functions

static Metricinstance ()
 

Private Types

using iostream = boost::asio::basic_socket_iostream< boost::asio::ip::tcp, std::chrono::steady_clock, boost::asio::wait_traits< std::chrono::steady_clock > >
 

Private Member Functions

iostreamGetDataStream ()
 
bool Connect ()
 
void SendBatch ()
 
void ScheduleSend ()
 
void ScheduleOverallStatusLog ()
 

Static Private Member Functions

static std::string FormatInfluxDBValue (bool value)
 
template<class T >
requires std::integral<T> && (!std::same_as<T, bool>)
static std::string FormatInfluxDBValue (T value)
 
static std::string FormatInfluxDBValue (std::string const &value)
 
static std::string FormatInfluxDBValue (char const *value)
 
static std::string FormatInfluxDBValue (double value)
 
static std::string FormatInfluxDBValue (float value)
 
static std::string FormatInfluxDBValue (std::chrono::nanoseconds value)
 
static std::string FormatInfluxDBTagValue (std::string const &value)
 

Private Attributes

std::unique_ptr< iostream_dataStream
 
MPSCQueue< MetricData, &MetricData::QueueLink_queuedData
 
std::unique_ptr< Trinity::Asio::DeadlineTimer_batchTimer
 
std::unique_ptr< Trinity::Asio::DeadlineTimer_overallStatusTimer
 
int32 _updateInterval = 0
 
int32 _overallStatusTimerInterval = 0
 
bool _enabled = false
 
bool _overallStatusTimerTriggered = false
 
std::string _hostname
 
std::string _port
 
std::string _databaseName
 
std::function< void()> _overallStatusLogger
 
std::string _realmName
 
std::unordered_map< std::string, int64, Trinity::TransparentHash< std::string_view >, std::equal_to<> > _thresholds
 

Detailed Description

Definition at line 60 of file Metric.h.

Member Typedef Documentation

◆ iostream

using Metric::iostream = boost::asio::basic_socket_iostream<boost::asio::ip::tcp, std::chrono::steady_clock, boost::asio::wait_traits<std::chrono::steady_clock> >
private

Definition at line 63 of file Metric.h.

Constructor & Destructor Documentation

◆ Metric() [1/3]

Metric::Metric ( )

Definition at line 320 of file Metric.cpp.

◆ ~Metric()

Metric::~Metric ( )

Definition at line 324 of file Metric.cpp.

◆ Metric() [2/3]

Metric::Metric ( Metric const &  )
delete

◆ Metric() [3/3]

Metric::Metric ( Metric &&  )
delete

Member Function Documentation

◆ Connect()

bool Metric::Connect ( )
private

Definition at line 37 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FormatInfluxDBTagValue()

std::string Metric::FormatInfluxDBTagValue ( std::string const &  value)
staticprivate

Definition at line 309 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FormatInfluxDBValue() [1/7]

std::string Metric::FormatInfluxDBValue ( bool  value)
staticprivate

Definition at line 273 of file Metric.cpp.

+ Here is the caller graph for this function:

◆ FormatInfluxDBValue() [2/7]

std::string Metric::FormatInfluxDBValue ( char const *  value)
staticprivate

Definition at line 294 of file Metric.cpp.

+ Here is the call graph for this function:

◆ FormatInfluxDBValue() [3/7]

std::string Metric::FormatInfluxDBValue ( double  value)
staticprivate

Definition at line 299 of file Metric.cpp.

◆ FormatInfluxDBValue() [4/7]

std::string Metric::FormatInfluxDBValue ( float  value)
staticprivate

Definition at line 304 of file Metric.cpp.

+ Here is the call graph for this function:

◆ FormatInfluxDBValue() [5/7]

std::string Metric::FormatInfluxDBValue ( std::chrono::nanoseconds  value)
staticprivate

Definition at line 315 of file Metric.cpp.

+ Here is the call graph for this function:

◆ FormatInfluxDBValue() [6/7]

std::string Metric::FormatInfluxDBValue ( std::string const &  value)
staticprivate

Definition at line 286 of file Metric.cpp.

+ Here is the call graph for this function:

◆ FormatInfluxDBValue() [7/7]

template<class T >
requires std::integral<T> && (!std::same_as<T, bool>)
std::string Metric::FormatInfluxDBValue ( value)
staticprivate

Definition at line 279 of file Metric.cpp.

◆ GetDataStream()

iostream & Metric::GetDataStream ( )
inlineprivate

Definition at line 65 of file Metric.h.

+ Here is the caller graph for this function:

◆ Initialize()

void Metric::Initialize ( std::string const &  realmName,
Trinity::Asio::IoContext ioContext,
std::function< void()>  overallStatusLogger 
)

Definition at line 27 of file Metric.cpp.

+ Here is the call graph for this function:

◆ instance()

Metric * Metric::instance ( )
static

Definition at line 328 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsEnabled()

bool Metric::IsEnabled ( ) const
inline

Definition at line 157 of file Metric.h.

◆ LoadFromConfigs()

void Metric::LoadFromConfigs ( )

Definition at line 51 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LogEvent()

void Metric::LogEvent ( std::string_view  category,
std::string_view  title,
std::string  description 
)

Definition at line 123 of file Metric.cpp.

◆ LogValue()

template<class T , class... TagsList>
void Metric::LogValue ( std::string_view  category,
value,
TagsList &&...  tags 
)
inlinenoexcept

Definition at line 114 of file Metric.h.

◆ operator=() [1/2]

Metric & Metric::operator= ( Metric &&  )
delete

◆ operator=() [2/2]

Metric & Metric::operator= ( Metric const &  )
delete

◆ ScheduleOverallStatusLog()

void Metric::ScheduleOverallStatusLog ( )
private

Definition at line 260 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ScheduleSend()

void Metric::ScheduleSend ( )
private

Definition at line 230 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBatch()

void Metric::SendBatch ( )
private

Definition at line 137 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShouldLog()

bool Metric::ShouldLog ( std::string_view  category,
int64  value 
) const

Definition at line 115 of file Metric.cpp.

◆ Unload()

void Metric::Unload ( )

Definition at line 247 of file Metric.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Update()

void Metric::Update ( )

Definition at line 106 of file Metric.cpp.

Member Data Documentation

◆ _batchTimer

std::unique_ptr<Trinity::Asio::DeadlineTimer> Metric::_batchTimer
private

Definition at line 68 of file Metric.h.

◆ _databaseName

std::string Metric::_databaseName
private

Definition at line 76 of file Metric.h.

◆ _dataStream

std::unique_ptr<iostream> Metric::_dataStream
private

Definition at line 66 of file Metric.h.

◆ _enabled

bool Metric::_enabled = false
private

Definition at line 72 of file Metric.h.

◆ _hostname

std::string Metric::_hostname
private

Definition at line 74 of file Metric.h.

◆ _overallStatusLogger

std::function<void()> Metric::_overallStatusLogger
private

Definition at line 77 of file Metric.h.

◆ _overallStatusTimer

std::unique_ptr<Trinity::Asio::DeadlineTimer> Metric::_overallStatusTimer
private

Definition at line 69 of file Metric.h.

◆ _overallStatusTimerInterval

int32 Metric::_overallStatusTimerInterval = 0
private

Definition at line 71 of file Metric.h.

◆ _overallStatusTimerTriggered

bool Metric::_overallStatusTimerTriggered = false
private

Definition at line 73 of file Metric.h.

◆ _port

std::string Metric::_port
private

Definition at line 75 of file Metric.h.

◆ _queuedData

MPSCQueue<MetricData, &MetricData::QueueLink> Metric::_queuedData
private

Definition at line 67 of file Metric.h.

◆ _realmName

std::string Metric::_realmName
private

Definition at line 78 of file Metric.h.

◆ _thresholds

std::unordered_map<std::string, int64, Trinity::TransparentHash<std::string_view>, std::equal_to<> > Metric::_thresholds
private

Definition at line 79 of file Metric.h.

◆ _updateInterval

int32 Metric::_updateInterval = 0
private

Definition at line 70 of file Metric.h.


The documentation for this class was generated from the following files: