#metrics-exporter #prometheus-metrics #prometheus-exporter

pomfrit

Prometheus metrics exporter with hot reload

10 releases

0.1.9 Oct 17, 2022
0.1.8 Aug 2, 2022
0.1.7 Jun 13, 2022
0.1.6 Apr 3, 2022
0.1.0 Dec 10, 2021

#28 in #prometheus-exporter

Download history 6/week @ 2024-07-20 6/week @ 2024-07-27 5/week @ 2024-08-03 7/week @ 2024-08-10 2/week @ 2024-08-17 6/week @ 2024-08-24 12/week @ 2024-08-31 12/week @ 2024-09-07 4/week @ 2024-09-14 41/week @ 2024-09-21 47/week @ 2024-09-28 22/week @ 2024-10-05 22/week @ 2024-10-12 21/week @ 2024-10-19 13/week @ 2024-10-26 11/week @ 2024-11-02

69 downloads per month

Custom license

24KB
497 lines

pomfrit

Prometheus metrics exporter with hot reload

Example:

use pomfrit::formatter::*;

/// Your metrics as a struct
struct MyMetrics<'a> {
    ctx: &'a str,
    some_diff: u32,
    some_time: u32,
}

/// Describe how your metrics will be displayed
impl std::fmt::Display for MyMetrics<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.begin_metric("some_diff")
            .label("label1", self.ctx)
            .label("label2", "some value")
            .value(self.some_diff)?;

        f.begin_metric("some_time")
            .label("label1", self.ctx)
            .value(self.some_time)
    }
}

async fn my_app() {
    // Create inactive exporter
    let (exporter, writer) = pomfrit::create_exporter(None).await.unwrap();

    // Spawn task that will run in the background and write metrics
    writer.spawn(|buf| {
        buf.write(MyMetrics {
            ctx: "asd",
            some_diff: 123,
            some_time: 456,
        }).write(MyMetrics {
            ctx: "qwe",
            some_diff: 111,
            some_time: 444,
        });
    });

    // ...

    // Reload exporter config
    exporter.reload(Some(pomfrit::Config {
        collection_interval_sec: 10,
        ..Default::default()
    })).await.unwrap();
}

Why is it called pomfrit?

Pomfrit is fried potatoes. Something very simple and you order it in addition to the main course.

Dependencies

~0.4–10MB
~99K SLoC