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

#include <Metric.h>

Public Member Functions

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

Static Public Member Functions

static Metric * instance ()
 

Private Member Functions

std::iostream & GetDataStream ()
 
bool Connect ()
 
void SendBatch ()
 
void ScheduleSend ()
 
void ScheduleOverallStatusLog ()
 

Static Private Member Functions

static std::string FormatInfluxDBValue (bool value)
 
template<class T >
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< std::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 > _thresholds
 

Detailed Description

Definition at line 69 of file Metric.h.

Constructor & Destructor Documentation

◆ Metric()

Metric::Metric ( )

Definition at line 304 of file Metric.cpp.

◆ ~Metric()

Metric::~Metric ( )

Definition at line 308 of file Metric.cpp.

Member Function Documentation

◆ Connect()

bool Metric::Connect ( )
private

Definition at line 38 of file Metric.cpp.

References _enabled, _hostname, _port, GetDataStream(), and TC_LOG_ERROR.

Referenced by LoadFromConfigs(), and SendBatch().

◆ FormatInfluxDBTagValue()

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

Definition at line 293 of file Metric.cpp.

Referenced by Initialize(), and SendBatch().

◆ FormatInfluxDBValue() [1/7]

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

Definition at line 262 of file Metric.cpp.

Referenced by FormatInfluxDBValue(), FormatInfluxDBValue(), and FormatInfluxDBValue().

◆ FormatInfluxDBValue() [2/7]

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

Definition at line 278 of file Metric.cpp.

References FormatInfluxDBValue().

◆ FormatInfluxDBValue() [3/7]

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

Definition at line 283 of file Metric.cpp.

◆ FormatInfluxDBValue() [4/7]

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

Definition at line 288 of file Metric.cpp.

References FormatInfluxDBValue().

◆ FormatInfluxDBValue() [5/7]

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

Definition at line 299 of file Metric.cpp.

References FormatInfluxDBValue().

◆ FormatInfluxDBValue() [6/7]

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

Definition at line 273 of file Metric.cpp.

◆ FormatInfluxDBValue() [7/7]

template<class T >
std::string Metric::FormatInfluxDBValue ( T  value)
staticprivate

Definition at line 268 of file Metric.cpp.

◆ GetDataStream()

std::iostream & Metric::GetDataStream ( )
inlineprivate

Definition at line 72 of file Metric.h.

Referenced by Connect(), ScheduleSend(), and SendBatch().

◆ Initialize()

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

◆ instance()

Metric * Metric::instance ( )
static

Definition at line 312 of file Metric.cpp.

References instance().

Referenced by instance().

◆ IsEnabled()

bool Metric::IsEnabled ( ) const
inline

Definition at line 135 of file Metric.h.

◆ LoadFromConfigs()

◆ LogEvent()

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

◆ LogValue()

template<class T , class... Tags>
void Metric::LogValue ( std::string  category,
T  value,
Tags &&...  tags 
)
inline

◆ ScheduleOverallStatusLog()

void Metric::ScheduleOverallStatusLog ( )
private

◆ ScheduleSend()

void Metric::ScheduleSend ( )
private

Definition at line 219 of file Metric.cpp.

References _batchTimer, _enabled, _queuedData, _updateInterval, GetDataStream(), and SendBatch().

Referenced by LoadFromConfigs(), and SendBatch().

◆ SendBatch()

◆ ShouldLog()

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

Definition at line 118 of file Metric.cpp.

References _thresholds.

◆ Unload()

void Metric::Unload ( )

◆ Update()

void Metric::Update ( )

Definition at line 109 of file Metric.cpp.

References _overallStatusLogger, and _overallStatusTimerTriggered.

Member Data Documentation

◆ _batchTimer

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

Definition at line 75 of file Metric.h.

Referenced by Initialize(), ScheduleSend(), and Unload().

◆ _databaseName

std::string Metric::_databaseName
private

Definition at line 83 of file Metric.h.

Referenced by LoadFromConfigs(), and SendBatch().

◆ _dataStream

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

Definition at line 73 of file Metric.h.

Referenced by Initialize().

◆ _enabled

bool Metric::_enabled = false
private

Definition at line 79 of file Metric.h.

Referenced by Connect(), LoadFromConfigs(), ScheduleOverallStatusLog(), ScheduleSend(), and Unload().

◆ _hostname

std::string Metric::_hostname
private

Definition at line 81 of file Metric.h.

Referenced by Connect(), LoadFromConfigs(), and SendBatch().

◆ _overallStatusLogger

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

Definition at line 84 of file Metric.h.

Referenced by Initialize(), and Update().

◆ _overallStatusTimer

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

Definition at line 76 of file Metric.h.

Referenced by Initialize(), ScheduleOverallStatusLog(), and Unload().

◆ _overallStatusTimerInterval

int32 Metric::_overallStatusTimerInterval = 0
private

Definition at line 78 of file Metric.h.

Referenced by LoadFromConfigs(), and ScheduleOverallStatusLog().

◆ _overallStatusTimerTriggered

bool Metric::_overallStatusTimerTriggered = false
private

Definition at line 80 of file Metric.h.

Referenced by ScheduleOverallStatusLog(), and Update().

◆ _port

std::string Metric::_port
private

Definition at line 82 of file Metric.h.

Referenced by Connect(), LoadFromConfigs(), and SendBatch().

◆ _queuedData

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

Definition at line 74 of file Metric.h.

Referenced by LogEvent(), ScheduleSend(), and SendBatch().

◆ _realmName

std::string Metric::_realmName
private

Definition at line 85 of file Metric.h.

Referenced by Initialize(), and SendBatch().

◆ _thresholds

std::unordered_map<std::string, int64> Metric::_thresholds
private

Definition at line 86 of file Metric.h.

Referenced by LoadFromConfigs(), and ShouldLog().

◆ _updateInterval

int32 Metric::_updateInterval = 0
private

Definition at line 77 of file Metric.h.

Referenced by LoadFromConfigs(), and ScheduleSend().


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