FastMetrics
A pure-Rust implementation of the OpenMetrics specification for transmitting cloud-native metrics at scale, and it's compatible with Prometheus.
Features
- Full support for OpenMetrics specification
- Fast encoding in both text and (optional) protobuf exposition format
- Text
- Prometheus text:
0.0.4,1.0.0 - OpenMetrics text:
0.0.1,1.0.0 - V1 escaping schemes:
allow-utf-8,underscores,dots,values
- Prometheus text:
- Protobuf
- Text
- Customizable metric types (currently a set of commonly used metric types are provided)
- Hierarchical metric organization with namespaces and subsystems
- Support for variable and constant labels
- Derive macros to simplify code (e.g., like registering metrics, label handling, etc.)
Usage
use ;
// Define label types
// Need to enable `derive` feature to use `#[derive(LabelSet)]`
// or `#[derive(EncodeLabelSet, LabelSetSchema)]`
// Need to enable `derive` feature to use `#[derive(EncodeLabelValue)]`
// Need to enable `derive` feature to use `#[derive(Register)]`
See documentation and examples for more details.
Performance
See benchmarks for more details
Acknowledgment
I drew a lot of inspiration from the following libraries, retaining the designs I thought were good and experimenting with some different ones.
- prometheus/client_golang: Official prometheus client library for Golang applications.
- prometheus/client_rust: Official prometheus client library for Rust applications.
- tikv/rust-prometheus: Another prometheus instrumentation library for Rust applications.
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.