Metrics is a batteries-included instrumentation ecosystem for Rust, allowing you to quickly and easily instrument your libraries and applications.

High Performance

With a pay-for-what-you-use approach, Metrics has nearly zero cost when not in use, and is fully optimized for the lowest possible overhead when enabled. Confidently instrument your application without fear of production impact.

Pragmatic Design

Instrumentation should be easy to integrate and easy to use. Metrics provides an opinionated API to help you avoid wasting time when getting started, without locking you into a specific monitoring system or time-series database. Stop wasting time sorting through and implementing different instrumentation libraries: use Metrics, and do it once.

Working Together

Metrics provides a common framework for instrumentation. Using a Metrics-instrumented library in your application? Automatically get access to those metrics with no extra configuration. The more libraries that use Metrics, the richer the instrumentation gets for the entire Rust ecosystem. Use an instrumentation library that rewards collaboration.

See how it easy it is to get started:

Here is a code snippet to show how to use the metrics crate both as a library and application author.

1 use std::time::Instant; 2 use metrics::{increment, histogram}; 3 use metrics_exporter_prometheus::PrometheusBuilder; 4 5 // It's easy to instrument code: 6 fn process_request() { 7 increment!("requests_received"); 8 9 let start = Instant::now(); 10 11 // Do some work here... 12 13 histogram!("process_request_duration", start.elapsed()); 14 } 15 16 // And it's easy to start collecting metrics: 17 fn main() { 18 // Run a Prometheus scrape endpoint on 19 let _ = PrometheusBuilder::new() 20 .install() 21 .expect("failed to install prometheus exporter"); 22 } 23
100% ☰ 23/23 ln : 1

Ready to try metrics?

Want to get in touch?