@@ -39,9 +39,10 @@ pub mod common_macro_prelude {
39
39
pub use crate :: thread_local_aggregator:: create_map;
40
40
}
41
41
42
- /// The macro to define STATS module that contains static variables, one per counter you want to
43
- /// export. This is the main and recomended way to interact with statistics provided by this crate.
44
- /// If non empty prefix is passed then the exported counter name will be "{prefix}.{name}"
42
+ /// The macro to define STATS module that contains static variables, one per
43
+ /// counter you want to export. This is the main and recommended way to interact
44
+ /// with statistics provided by this crate. If non empty prefix is passed then
45
+ /// the exported counter name will be "{prefix}.{name}"
45
46
///
46
47
/// Examples:
47
48
/// ```
@@ -91,6 +92,70 @@ pub mod common_macro_prelude {
91
92
/// ALT_STATS::test_t2.add_value(1);
92
93
/// }
93
94
/// ```
95
+ ///
96
+ /// # Reference
97
+ ///
98
+ /// ## `singleton_counter`, `counter`
99
+ /// Raw counter types. These take an optional key parameter - if it is not
100
+ /// specified, then it's derived from the stat field name.
101
+ ///
102
+ /// These are deprecated in favor of `timeseries`.
103
+ ///
104
+ /// # `timeseries`
105
+ /// The general syntax for `timeseries` is:
106
+ /// ```text
107
+ /// timeseries(<optional key>; <list of aggregations>; [optional intervals])
108
+ /// ```
109
+ ///
110
+ /// If "optional key" is omitted then key is derived from the stat key name;
111
+ /// otherwise it's a string literal.
112
+ ///
113
+ /// "List of aggregations" is a slice of
114
+ /// [`AggregationType`](stats_traits::stats_manager::AggregationType) enum
115
+ /// values.
116
+ ///
117
+ /// "Optional intervals" is a slice of [`Duration`s](std::time::Duration). It
118
+ /// specifies over what time periods the aggregations aggregate. If not
119
+ /// specified, it typically defaults to 60 seconds.
120
+ ///
121
+ /// This maps to a call to
122
+ /// [`StatsManager::create_timeseries`](stats_traits::stats_manager::StatsManager::create_histogram).
123
+ ///
124
+ /// # `histogram`
125
+ /// The general syntax for `histogram` is:
126
+ /// ```text
127
+ /// histogram(<optional key>; bucket-width, min, max, <list of aggregations>; <P XX percentiles>)
128
+ /// ```
129
+ /// If "optional key" is omitted then key is derived from the stat key name;
130
+ /// otherwise it's a string literal.
131
+ ///
132
+ /// `bucket-width` specifies what range of values are accumulated into each
133
+ /// bucket; the larger it is the fewer buckets there are.
134
+ ///
135
+ /// `min` and `max` specify the min and max of the expected range of samples.
136
+ /// Samples outside this range will be aggregated into out-of-range buckets,
137
+ /// which means they're not lost entirely but they lead to inaccurate stats.
138
+ ///
139
+ /// Together the min, max and bucket width parameters determine how many buckets
140
+ /// are created.
141
+ ///
142
+ /// "List of aggregations" is a slice of
143
+ /// [`AggregationType`](stats_traits::stats_manager::AggregationType) enum
144
+ /// values.
145
+ ///
146
+ /// Percentiles are specified as `P NN` in a `;`-separated list, such as `P 20;
147
+ /// P 50; P 90; P 99`...
148
+ ///
149
+ /// This maps to a call to
150
+ /// [`StatsManager::create_histogram`](stats_traits::stats_manager::StatsManager::create_histogram).
151
+ ///
152
+ /// # `dynamic_counter`, `dynamic_timeseries`, `dynamic_histogram`
153
+ ///
154
+ /// These are equivalent to the corresponding `counter`/`timeseries`/`histogram`
155
+ /// above, except that they allow the key to have a dynamic component. The key
156
+ /// is no longer optional, but is instead specified with `<format-string>,
157
+ /// (variable:type, ...)`. The format string is standard
158
+ /// [`format!`](std::format).
94
159
#[ macro_export]
95
160
macro_rules! define_stats {
96
161
// Fill the optional prefix with empty string, all matching is repeated here to avoid the
0 commit comments