Crate stats

source ·
Expand description

Provides a macro define_stats! for creation of stats. This crate requires the caller to schedule aggregation of stats by calling schedule_stats_aggregation and executing the returned future.

Re-exports

Modules

  • A “prelude” of stats crate.
  • This module provides the means to define stats that are thread local and to schedule a periodic aggregation process of those stats.

Macros

  • The macro to define STATS module that contains static variables, one per counter you want to export. This is the main and recommended way to interact with statistics provided by this crate. If non empty prefix is passed then the exported counter name will be “{prefix}.{name}”
  • Define a group of stats with dynamic names all parameterized by the same set of parameters. The intention is that when setting up a structure for some entity with associated stats, then the type produced by this macro can be included in that structure, and initialized with the appropriate name(s). This is more efficient than using single static “dynamic_” versions of the counters.

Functions

  • This function must be called exactly once before accessing any of the stats, otherwise it will panic. If it won’t be called a default stats manager factory will be assumed that does nothing. (Facebook only: the default will use fb303 counters)