![]() |
TrinityCore
|
#include <Metric.h>
Public Member Functions | |
| Metric () | |
| ~Metric () | |
| Metric (Metric const &)=delete | |
| Metric (Metric &&)=delete | |
| Metric & | operator= (Metric const &)=delete |
| Metric & | operator= (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 Metric * | instance () |
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 | |
| iostream & | GetDataStream () |
| 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 |
|
private |
| Metric::Metric | ( | ) |
Definition at line 320 of file Metric.cpp.
| Metric::~Metric | ( | ) |
Definition at line 324 of file Metric.cpp.
|
delete |
|
delete |
|
private |
Definition at line 37 of file Metric.cpp.
References _enabled, _hostname, _port, GetDataStream(), and TC_LOG_ERROR.
Referenced by LoadFromConfigs(), and SendBatch().
|
staticprivate |
Definition at line 309 of file Metric.cpp.
References StringReplaceAll().
Referenced by Initialize(), and SendBatch().
|
staticprivate |
Definition at line 273 of file Metric.cpp.
Referenced by FormatInfluxDBValue(), FormatInfluxDBValue(), and FormatInfluxDBValue().
|
staticprivate |
Definition at line 294 of file Metric.cpp.
References FormatInfluxDBValue().
|
staticprivate |
Definition at line 299 of file Metric.cpp.
|
staticprivate |
Definition at line 304 of file Metric.cpp.
References FormatInfluxDBValue().
|
staticprivate |
Definition at line 315 of file Metric.cpp.
References FormatInfluxDBValue().
|
staticprivate |
Definition at line 286 of file Metric.cpp.
References StringReplaceAll().
|
staticprivate |
Definition at line 279 of file Metric.cpp.
|
inlineprivate |
Definition at line 65 of file Metric.h.
Referenced by Connect(), ScheduleSend(), and SendBatch().
| void Metric::Initialize | ( | std::string const & | realmName, |
| Trinity::Asio::IoContext & | ioContext, | ||
| std::function< void()> | overallStatusLogger | ||
| ) |
Definition at line 27 of file Metric.cpp.
References _batchTimer, _dataStream, _overallStatusLogger, _overallStatusTimer, _realmName, FormatInfluxDBTagValue(), and LoadFromConfigs().
|
static |
| void Metric::LoadFromConfigs | ( | ) |
Definition at line 51 of file Metric.cpp.
References _databaseName, _enabled, _hostname, _overallStatusTimerInterval, _port, _thresholds, _updateInterval, Connect(), ScheduleOverallStatusLog(), ScheduleSend(), sConfigMgr, TC_LOG_ERROR, and Trinity::Tokenize().
Referenced by Initialize().
| void Metric::LogEvent | ( | std::string_view | category, |
| std::string_view | title, | ||
| std::string | description | ||
| ) |
Definition at line 123 of file Metric.cpp.
References _queuedData, MetricData::Category, and METRIC_DATA_EVENT.
|
inlinenoexcept |
Definition at line 114 of file Metric.h.
References MetricData::Category, METRIC_DATA_VALUE, and MetricData::Tags.
|
private |
Definition at line 260 of file Metric.cpp.
References _enabled, _overallStatusTimer, _overallStatusTimerInterval, _overallStatusTimerTriggered, and ScheduleOverallStatusLog().
Referenced by LoadFromConfigs(), and ScheduleOverallStatusLog().
|
private |
Definition at line 230 of file Metric.cpp.
References _batchTimer, _enabled, _queuedData, _updateInterval, GetDataStream(), and SendBatch().
Referenced by LoadFromConfigs(), and SendBatch().
|
private |
Definition at line 137 of file Metric.cpp.
References _databaseName, _hostname, _port, _queuedData, _realmName, MetricData::Category, Connect(), FormatInfluxDBTagValue(), GetDataStream(), METRIC_DATA_EVENT, METRIC_DATA_VALUE, ScheduleSend(), MetricData::Tags, TC_LOG_ERROR, MetricData::Timestamp, MetricData::Title, MetricData::Type, and MetricData::ValueOrEventText.
Referenced by ScheduleSend(), and Unload().
| bool Metric::ShouldLog | ( | std::string_view | category, |
| int64 | value | ||
| ) | const |
Definition at line 115 of file Metric.cpp.
References _thresholds.
| void Metric::Unload | ( | ) |
Definition at line 247 of file Metric.cpp.
References _batchTimer, _enabled, _overallStatusTimer, Trinity::Asio::get_io_context(), and SendBatch().
Referenced by main().
| void Metric::Update | ( | ) |
Definition at line 106 of file Metric.cpp.
References _overallStatusLogger, and _overallStatusTimerTriggered.
|
private |
Definition at line 68 of file Metric.h.
Referenced by Initialize(), ScheduleSend(), and Unload().
|
private |
Definition at line 76 of file Metric.h.
Referenced by LoadFromConfigs(), and SendBatch().
|
private |
Definition at line 66 of file Metric.h.
Referenced by Initialize().
|
private |
Definition at line 72 of file Metric.h.
Referenced by Connect(), LoadFromConfigs(), ScheduleOverallStatusLog(), ScheduleSend(), and Unload().
|
private |
Definition at line 74 of file Metric.h.
Referenced by Connect(), LoadFromConfigs(), and SendBatch().
|
private |
Definition at line 77 of file Metric.h.
Referenced by Initialize(), and Update().
|
private |
Definition at line 69 of file Metric.h.
Referenced by Initialize(), ScheduleOverallStatusLog(), and Unload().
|
private |
Definition at line 71 of file Metric.h.
Referenced by LoadFromConfigs(), and ScheduleOverallStatusLog().
|
private |
Definition at line 73 of file Metric.h.
Referenced by ScheduleOverallStatusLog(), and Update().
|
private |
Definition at line 75 of file Metric.h.
Referenced by Connect(), LoadFromConfigs(), and SendBatch().
|
private |
Definition at line 67 of file Metric.h.
Referenced by LogEvent(), ScheduleSend(), and SendBatch().
|
private |
Definition at line 78 of file Metric.h.
Referenced by Initialize(), and SendBatch().
|
private |
Definition at line 79 of file Metric.h.
Referenced by LoadFromConfigs(), and ShouldLog().
|
private |
Definition at line 70 of file Metric.h.
Referenced by LoadFromConfigs(), and ScheduleSend().