Crates.io | vise-exporter |
lib.rs | vise-exporter |
version | 0.2.0 |
source | src |
created_at | 2024-07-05 07:14:39.375173 |
updated_at | 2024-08-07 11:51:51.884023 |
description | Prometheus exporter for metrics defined using `vise` |
homepage | |
repository | https://github.com/matter-labs/vise |
max_upload_size | |
id | 1292426 |
size | 44,356 |
vise
This crate provides a simple Prometheus metrics exporter for metrics defined
using vise
. It is based on the hyper
library and supports both pull-based
and push-based communication with Prometheus.
Add this to your Crate.toml:
[dependencies]
vise-exporter = "0.2.0"
An exporter can be initialized from a metrics Registry
:
use tokio::sync::watch;
use vise_exporter::MetricsExporter;
async fn my_app() {
let (shutdown_sender, mut shutdown_receiver) = watch::channel(());
let exporter = MetricsExporter::default()
.with_graceful_shutdown(async move {
shutdown_receiver.changed().await.ok();
});
let bind_address = "0.0.0.0:3312".parse().unwrap();
tokio::spawn(exporter.start(bind_address));
// Then, once the app is shutting down:
shutdown_sender.send_replace(());
}
See crate docs for more examples.
Distributed under the terms of either
at your option.