Crates.io | promformat |
lib.rs | promformat |
version | 0.4.1 |
source | src |
created_at | 2023-03-19 21:00:11.387916 |
updated_at | 2023-03-26 12:13:30.303889 |
description | Simple formatter for prometheus metrics |
homepage | https://github.com/vmalloc/promformat |
repository | |
max_upload_size | |
id | 814691 |
size | 6,407 |
promformat
is a small utility library to help formatting Prometheus metrics.
In most cases exposing Prometheus metrics in Rust can be easily done using the prometheus
crate, using global counters registered as lazy_static!
s or similar tricks. However this can have potential downsides to some use cases.
For example, you may want to set and unset metrics based on varying conditions, or register/unregister specific label sets. Such a task is tricky and cumbersome to achieve in the prometheus
crate.
Using promformat
is pretty straightforward:
use promformat::Metrics;
let mut metrics = Metrics::new();
let mut gauge1 = metrics.gauge("gauge_1", "Some gauge help text here");
gauge1.label("label1", "value1").label("label2", "value2").set(100);
let rendered = metrics.render();
promformat
is licensed under the Apache 2.0 license