Foundational traits for interoperable metrics libraries in Rust.
Most libraries, under the hood, are all based around a core set of data types: counters, gauges, and histograms. While the API surface may differ, the underlying data is the same.
Counters represent a single value that can only ever be incremented over time, or reset to zero.
Counters are useful for tracking things like operations completed, or errors raised, where the value naturally begins at zero when a process or service is started or restarted.
Gauges represent a single value that can go up or down over time.
Gauges are useful for tracking things like the current number of connected users, or a stock price, or the temperature outside.
Histograms measure the distribution of values for a given set of measurements.
Histograms are generally used to derive statistics about a particular measurement from an operation or event that happens over and over, such as the duration of a request, or number of rows returned by a particular database query.
Histograms allow you to answer questions of these measurements, such as:
- "What were the fastest and slowest requests in this window?"
- "What is the slowest request we've seen out of 90% of the requests measured? 99%?"
Histograms are a convenient way to measure behavior not only at the median, but at the edges of normal operating behavior.
A value which can be converted into a nanosecond representation.
A value that can provide on-demand snapshots asynchronously.
A value that records metrics.
A value that holds a point-in-time view of collected metrics.
A value that can provide on-demand snapshots.
An optimized metric key.