2 unstable releases

0.2.0 Aug 7, 2024
0.1.0 Jul 5, 2024

#903 in Development tools

Download history 4823/week @ 2024-11-16 4168/week @ 2024-11-23 3997/week @ 2024-11-30 3924/week @ 2024-12-07 4936/week @ 2024-12-14 516/week @ 2024-12-21 1919/week @ 2024-12-28 4639/week @ 2025-01-04 5927/week @ 2025-01-11 4849/week @ 2025-01-18 3854/week @ 2025-01-25 3188/week @ 2025-02-01 4634/week @ 2025-02-08 4097/week @ 2025-02-15 2794/week @ 2025-02-22 4990/week @ 2025-03-01

17,266 downloads per month
Used in 62 crates (2 directly)

MIT/Apache

155KB
3K SLoC

Metrics Exporter for vise

Build Status License: MIT OR Apache-2.0 rust 1.70+ 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.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.

License

Distributed under the terms of either

at your option.

Dependencies

~6–17MB
~213K SLoC