4 releases (2 breaking)

new 0.3.1 Jun 5, 2025
0.3.0 Apr 14, 2025
0.2.0 Aug 7, 2024
0.1.0 Jul 5, 2024

#523 in Debugging

Download history 3906/week @ 2025-02-12 3541/week @ 2025-02-19 4251/week @ 2025-02-26 5303/week @ 2025-03-05 5208/week @ 2025-03-12 5669/week @ 2025-03-19 3546/week @ 2025-03-26 651/week @ 2025-04-02 662/week @ 2025-04-09 1404/week @ 2025-04-16 4844/week @ 2025-04-23 6321/week @ 2025-04-30 5276/week @ 2025-05-07 5186/week @ 2025-05-14 7085/week @ 2025-05-21 5826/week @ 2025-05-28

24,700 downloads per month
Used in 63 crates (3 directly)

MIT/Apache

175KB
3K SLoC

Metrics Exporter for vise

Build Status License: MIT OR Apache-2.0 rust 1.79+ required

Documentation: crate docs (main)

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.

Usage

Add this to your Crate.toml:

[dependencies]
vise-exporter = "0.3.1"

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.

License

Distributed under the terms of either

at your option.

Dependencies

~6–15MB
~176K SLoC