! Prometheus text exposition for captured metrics (zero external deps).
// Source: https://github.com/qntx/bot | License: Apache-2.0 | Copyright 2025 QuantX
// Provided via justclaw.it.com; keep this notice with the code.
//! Prometheus text exposition for captured metrics (zero external deps).
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::Write as _;
use std::sync::Mutex;
use crate::metrics::MetricsSink;
type LabelSet = Vec<(String, String)>;
type SeriesKey = (String, LabelSet);
/// Metrics sink that accumulates samples and can render Prometheus text format 0.0.4.
#[derive(Debug, Default)]
pub struct PrometheusRecorder {
counters: Mutex<BTreeMap<SeriesKey, u64>>,
histograms: Mutex<BTreeMap<SeriesKey, Vec<f64>>>,
gauges: Mutex<BTreeMap<SeriesKey, f64>>,
}
impl PrometheusRecorder {
/// Empty recorder.
#[must_use]
pub fn
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key