https://github.com/broxus/pomfrit
A simple Prometheus metrics exporter with hot reload
https://github.com/broxus/pomfrit
metrics prometheus rust
Last synced: 9 months ago
JSON representation
A simple Prometheus metrics exporter with hot reload
- Host: GitHub
- URL: https://github.com/broxus/pomfrit
- Owner: broxus
- License: mit
- Created: 2021-12-09T20:32:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-17T18:30:04.000Z (over 3 years ago)
- Last Synced: 2025-09-18T11:25:08.598Z (9 months ago)
- Topics: metrics, prometheus, rust
- Language: Rust
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## pomfrit
Prometheus metrics exporter with hot reload
### Example:
```rust
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.