TrinityCore
Loading...
Searching...
No Matches
Metric.h File Reference
#include "AsioHacksFwd.h"
#include "Define.h"
#include "Duration.h"
#include "Hash.h"
#include "MPSCQueue.h"
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
#include <utility>
#include <variant>
+ Include dependency graph for Metric.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  MetricData
 
class  Metric
 
struct  MetricStopWatchBase
 
struct  MetricStopWatch< LoggerType >
 

Macros

#define sMetric   Metric::instance()
 
#define TC_METRIC_TAG(name, value)   std::pair<std::string_view, std::string_view>(name, value)
 
#define TC_METRIC_DO_CONCAT(a, b)   a ## b
 
#define TC_METRIC_CONCAT(a, b)   TC_METRIC_DO_CONCAT(a, b)
 
#define TC_METRIC_UNIQUE_NAME(name)   TC_METRIC_CONCAT(name, __LINE__)
 
#define TC_METRIC_EVENT(category, title, description)
 
#define TC_METRIC_VALUE(category, value, ...)
 
#define TC_METRIC_TIMER_IMPL(variable, category, ...)
 
#define TC_METRIC_TIMER(category, ...)   TC_METRIC_TIMER_IMPL(TC_METRIC_UNIQUE_NAME(tc_metric_stop_watch_), category, ## __VA_ARGS__)
 
#define TC_METRIC_DETAILED_EVENT(category, title, description)   ((void)0)
 
#define TC_METRIC_DETAILED_TIMER(category, ...)   ((void)0)
 
#define TC_METRIC_DETAILED_NO_THRESHOLD_TIMER(category, ...)   ((void)0)
 

Typedefs

using MetricTag = std::pair< std::string, std::string >
 
using MetricTags = std::variant< std::monostate, std::array< MetricTag, 2 >, std::vector< MetricTag > >
 

Enumerations

enum  MetricDataType { METRIC_DATA_VALUE , METRIC_DATA_EVENT }
 

Functions

template<typename LoggerType >
 MetricStopWatch (LoggerType) -> MetricStopWatch< LoggerType >
 

Macro Definition Documentation

◆ sMetric

#define sMetric   Metric::instance()

Definition at line 160 of file Metric.h.

◆ TC_METRIC_CONCAT

#define TC_METRIC_CONCAT (   a,
 
)    TC_METRIC_DO_CONCAT(a, b)

Definition at line 190 of file Metric.h.

◆ TC_METRIC_DETAILED_EVENT

#define TC_METRIC_DETAILED_EVENT (   category,
  title,
  description 
)    ((void)0)

Definition at line 239 of file Metric.h.

◆ TC_METRIC_DETAILED_NO_THRESHOLD_TIMER

#define TC_METRIC_DETAILED_NO_THRESHOLD_TIMER (   category,
  ... 
)    ((void)0)

Definition at line 241 of file Metric.h.

◆ TC_METRIC_DETAILED_TIMER

#define TC_METRIC_DETAILED_TIMER (   category,
  ... 
)    ((void)0)

Definition at line 240 of file Metric.h.

◆ TC_METRIC_DO_CONCAT

#define TC_METRIC_DO_CONCAT (   a,
 
)    a ## b

Definition at line 189 of file Metric.h.

◆ TC_METRIC_EVENT

#define TC_METRIC_EVENT (   category,
  title,
  description 
)
Value:
do { \
if (Metric* metric = sMetric; metric->IsEnabled()) \
metric->LogEvent(category, title, description); \
} while (false)
#define sMetric
Definition Metric.h:160
bool IsEnabled() const
Definition Metric.h:157

Definition at line 201 of file Metric.h.

◆ TC_METRIC_TAG

#define TC_METRIC_TAG (   name,
  value 
)    std::pair<std::string_view, std::string_view>(name, value)

Definition at line 187 of file Metric.h.

◆ TC_METRIC_TIMER

#define TC_METRIC_TIMER (   category,
  ... 
)    TC_METRIC_TIMER_IMPL(TC_METRIC_UNIQUE_NAME(tc_metric_stop_watch_), category, ## __VA_ARGS__)

Definition at line 221 of file Metric.h.

◆ TC_METRIC_TIMER_IMPL

#define TC_METRIC_TIMER_IMPL (   variable,
  category,
  ... 
)
Value:
MetricStopWatch variable{ [&](Metric* metric, TimePoint start) \
{ \
metric->LogValue(category, std::chrono::steady_clock::now() - start, ## __VA_ARGS__); \
} }; \
do \
{ \
if (Metric* metric = sMetric; metric->IsEnabled()) \
variable.Enable(metric); \
} while (false)
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
Definition Duration.h:40
void LogValue(std::string_view category, T value, TagsList &&... tags) noexcept
Definition Metric.h:114

Definition at line 211 of file Metric.h.

◆ TC_METRIC_UNIQUE_NAME

#define TC_METRIC_UNIQUE_NAME (   name)    TC_METRIC_CONCAT(name, __LINE__)

Definition at line 191 of file Metric.h.

◆ TC_METRIC_VALUE

#define TC_METRIC_VALUE (   category,
  value,
  ... 
)
Value:
do { \
if (Metric* metric = sMetric; metric->IsEnabled()) \
metric->LogValue(category, value, ## __VA_ARGS__); \
} while (false)

Definition at line 206 of file Metric.h.

Typedef Documentation

◆ MetricTag

using MetricTag = std::pair<std::string, std::string>

Definition at line 39 of file Metric.h.

◆ MetricTags

using MetricTags = std::variant<std::monostate, std::array<MetricTag, 2>, std::vector<MetricTag> >

Definition at line 40 of file Metric.h.

Enumeration Type Documentation

◆ MetricDataType

Enumerator
METRIC_DATA_VALUE 
METRIC_DATA_EVENT 

Definition at line 33 of file Metric.h.

Function Documentation

◆ MetricStopWatch()

template<typename LoggerType >
MetricStopWatch ( LoggerType  ) -> MetricStopWatch< LoggerType >