Required Software

Statistic and metric logging in TrinityCore is implemented using two projects, InfluxDB, a time-series data storage and Grafana, graph and dashboard builder for visualizing time series metrics.

Adding new metrics

There are two kinds of metrics that can be logged: values and events.

Values correspond to measurements of a certain quantity, like number of online players or the update diff time.

Events are something that occurs in an instant of time, e.g, a player login, worldserver shutdown, etc..

To log new metrics, call TC_METRIC_EVENT or TC_METRIC_VALUE and add a new graph to the dashboard.

TC_METRIC_EVENT(category, title, description)
TC_METRIC_VALUE(category, value)

 

// Registering player logins: in WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
TC_METRIC_EVENT("player_events", "Login", pCurrChar->GetName());
 
// Logging the update diff time: in World::Update(uint32 diff)
TC_METRIC_VALUE("update_time_diff", diff);
 

Additional Reading

Learn more about InfluxDB and Grafana: