#metrics #prometheus #compatibility #install #collector #counter

metrics-prometheus-client

metricsprometheus_client之间创建兼容性

1个不稳定版本

0.0.1 2024年7月21日

#44#collector

Download history 70/week @ 2024-07-15 39/week @ 2024-07-22 5/week @ 2024-07-29

114 每月下载量

MIT/Apache

13KB
246

metrics-prometheus-client

metricsprometheus_client之间创建兼容性。

用法

use metrics_prometheus_client::install;
use prometheus_client::{encoding::text::encode, registry::Registry};

let collector = install();

// Use `metrics` crate interfaces.
metrics::counter!("count", "whose" => "mine", "kind" => "owned").increment(1);

let mut registry = Registry::default();
registry.register_collector(Box::new(collector));

let mut report = String::new();
encode(&mut report, &registry).unwrap();

assert_eq!(
    report.trim(),
    "# HELP count \n# TYPE count counter\ncount_total{whose=\"mine\",kind=\"owned\"} 1\n# EOF"
        .trim(),
);

依赖项

~1.6–7MB
~46K SLoC