core.statsmanager

Configuration

See our documentation configuring statistics.

Reporting statistics

Reporting statistics from plugins is preferably done using the module:measure() Module API method. This generates an internal name like "/hostname/mod_pluginname/some:counter"

See documentation about util.statistics.

local ctr = module:measure("some", "counter");
ctr(123); -- reports the value 123 for the 'some' counter

For use in other core modules or more control over the name generated

local measure = require "core.modulemanager".measure;

local ctr = measure("counter", "some");

Retrieving statistics

Note: This is only useful if internal statistics collection is used.

The function get_stats() returns three tables:

  • Map of values for all measures, even if it has not been reported since the last collection
  • Map of values reported during the last collection
  • Extra data attached to measures
local latest_stats, changed_stats, stats_extra = statsmanager.get_stats();

local latest_value, some_extra = statsmanager.get("some:counter");