NOTE: All conversations and contributions to this project shall adhere to the Code of Conduct.
Running applications in production can be hard when you don't have insight into what the application is doing. We're lucky to have so many good system monitoring programs and services to show us how our servers are performing, but we still have to do the work of instrumenting our applications to gain deep insight into their behavior and performance.
metrics
makes it easy to instrument your application to provide real-time insight into what's happening. It provides a number of practical features that make it easy for library and application authors to start collecting and exporting metrics from their codebase.
Some of the most common scenarios for collecting metrics from an application:
- see how many times a codepath was hit
- track the time it takes for a piece of code to execute
- expose internal counters and values in a standardized way
Importantly, this works for both library authors and application authors. If the libraries you use are instrumented, you unlock the power of being able to collect those metrics in your application for free, without any extra configuration. Everyone wins, and learns more about their application performance at the end of the day.
The Metrics project provides a number of crates for both library and application authors.
If you're a library author, you'll only care about using metrics
to instrument your library. If you're an application author, you'll likely also want to instrument your application, but you'll care about "exporters" as a means to take those metrics and ship them somewhere for analysis.
Overall, this repository is home to the following crates:
metrics
: A lightweight metrics facade, similar tolog
.metrics-macros
: Procedural macros that powermetrics
.metrics-tracing-context
: Allow capturingtracing
span fields as metric labels.metrics-exporter-tcp
: Ametrics
-compatible exporter for serving metrics over TCP.metrics-exporter-prometheus
: Ametrics
-compatible exporter for serving a Prometheus scrape endpoint.metrics-util
: Helper types/functions used by themetrics
ecosystem.
As well, there are also some community-maintained exporters and other integrations:
metrics-exporter-statsd
: Ametrics
-compatible exporter for sending metrics via StatsD.metrics-exporter-newrelic
: Ametrics
-compatible exporter for sending metrics to New Relic.opinionated_metrics
: Opinionated interface to emitting metrics for CLi/server applications, based onmetrics
.
Minimum Supported Rust version is 1.56.1. It is enforced in CI.
- The last 4 stable releases must always be supported
- Goal is to try and support older versions where possible (not opting in to newer versions just to use a new helper method on standard library types, etc)
- Do not bump the MSRV for newer versions of dependencies in core crates (metrics and metrics-util)
To those of you who have already contributed to metrics
in some way, shape, or form: a big, and continued, "thank you!" โค๏ธ
To everyone else that we haven't had the pleasure of interacting with: we're always looking for thoughts on how to make metrics
better, or users with interesting use cases. Of course, we're also happy to accept code contributions for outstanding feature requests directly. ๐
We'd love to chat about any of the above, or anything else related to metrics. Don't hesitate to file an issue on the repository, or come and chat with us over on Discord.