3 releases (breaking)

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

#585 in Science

Download history 462/week @ 2024-12-23 1981/week @ 2024-12-30 5092/week @ 2025-01-06 5824/week @ 2025-01-13 4408/week @ 2025-01-20 3870/week @ 2025-01-27 3188/week @ 2025-02-03 4705/week @ 2025-02-10 4154/week @ 2025-02-17 2705/week @ 2025-02-24 5813/week @ 2025-03-03 4802/week @ 2025-03-10 6116/week @ 2025-03-17 4842/week @ 2025-03-24 1035/week @ 2025-03-31 539/week @ 2025-04-07

12,633 downloads per month
Used in 62 crates (2 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.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–15MB
~177K SLoC