Macro slog_extlog::define_stats
[−]
[src]
macro_rules! define_stats { ($name:ident = {$($stat:ident($stype:ident, $desc:expr, [$($tags:tt),*])),*}) => { ... }; (@single $stat:ident, $stype:ident, $desc:expr, $($tags:tt),*) => { ... }; ($name:ident = {$($stat:ident($stype:ident, $id:expr, $desc:expr, [$($tags:tt),*])),*}) => { ... }; }
A macro to define the statistics that can be tracked by the logger.
Use of this macro requires StatDefinition to be in scope.
All statistics should be defined by their library using this macro.
The syntax is as follows:
define_stats!{
STATS_LIST_NAME = {
StatName(Type, "Description", ["tag1, "tag2", ...]),
Stat Name2(...),
...
}
}
The STATS_LIST_NAME is then created as a vector of definitions that can be passed in as the
stats field on a StatsConfig object.
Each definition in the list has the format above, with the fields as follows.
StatNameis the externally-facing metric name.Typeis theStatTypeof this statistic, for exampleCounter. Must be a valid subtype if that enum.Descriptionis a human readable description of the statistic. This will be logged as the log message,- The list of
tagsdefine field names to group the statistic by. A non-empty list indicates that this statistic should be split into buckets, counting the stat separately for each different value of these fields that is seen. These might be a remote hostname, say, or a tag field.- If multiple tags are provided, the stat is counted separately for all distinct combinations of tag values.
- Use of this feature should be avoided for fields that can take very many values, such as a subscriber number, or for large numbers of tags - each tag name and seen value adds a performance dip and a small memory overhead that is never freed.