[−][src]Crate metrics_core
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
Key | A metric key. |
Label | A key/value pair used to further describe a metric. |
Traits
AsNanoseconds | Used to do a nanosecond conversion. |
Builder | A value that can build an observer. |
Drain | A value that can produce a |
IntoLabels | A value that can be converted to |
Observe | A value whose metrics can be observed by an |
Observer | A value that observes metrics. |
Type Definitions
ScopedString | An allocation-optimized string. |