# prometheus-extensions
Prometheus extensions for richer metric collection in Rust.
## Types
| `AggregateCounter` | A `CounterVec` wrapper that automatically emits an extra unlabeled total alongside every per-label counter. |
| `ScientificEncoder` | A Prometheus text-format encoder that renders values in scientific notation with a trailing comma after the last label (Kafka JMX exporter compatible). |
| `Sensor` | A lock-free exponential moving average (EMA) gauge for tracking smoothed rates. |
## Usage
```rust
use prometheus::Opts;
use prometheus::core::Collector;
use prometheus_extensions::{AggregateCounter, ScientificEncoder};
let counter = AggregateCounter::new(
Opts::new("http_requests_total", "Total HTTP requests"),
&["method"],
).unwrap();
counter.with_label_values(&["GET"]).inc_by(100.0);
counter.with_label_values(&["POST"]).inc_by(42.0);
// Collecting yields 3 metrics: unlabeled total (142) + two labeled.
let families = counter.collect();
// Encode in scientific notation
let encoder = ScientificEncoder::new();
let mut buf = Vec::new();
encoder.encode(&families, &mut buf).unwrap();
```
## License
Licensed under either of [Apache License, Version 2.0](LICENSE-APACHE)
or [MIT license](LICENSE-MIT) at your option.