Expand description
Foundational traits for interoperable metrics libraries in Rust.
§Common Ground
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.
§Metric Types
§Counters
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
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
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.
Macros§
- labels
- Helper macro for generating a set of labels.
Structs§
Traits§
- AsNanoseconds
- Used to do a nanosecond conversion.
- Builder
- A value that can build an observer.
- Drain
- A value that can produce a
T
by draining its content. - Into
Labels - A value that can be converted to
Label
s. - Observe
- A value whose metrics can be observed by an
Observer
. - Observer
- A value that observes metrics.
Type Aliases§
- Scoped
String - An allocation-optimized string.