pub fn render_prometheus(snap: &Snapshot) -> StringExpand description
Render a Snapshot in the Prometheus 0.0.4 text exposition format.
The string returned is a complete, self-contained response body
that may be served directly with a
Content-Type: text/plain; version=0.0.4; charset=utf-8 header.
ยงExamples
use dynomite::stats::{render_prometheus, PoolStats, ServerStats, ServiceInfo, Snapshot};
let snap = Snapshot {
info: ServiceInfo {
source: "node-a".into(),
version: "0.0.1".into(),
rack: "r1".into(),
dc: "dc1".into(),
},
pool: PoolStats::new("dyn_o_mite"),
server: ServerStats::new("redis_local"),
..Snapshot::default()
};
let text = render_prometheus(&snap);
assert!(text.contains("dynomite_build_info"));
assert!(text.contains("# TYPE dynomite_build_info gauge"));