6个版本 (3个重大变更)
0.4.1 | 2023年3月26日 |
---|---|
0.4.0 | 2023年3月20日 |
0.3.0 | 2023年3月20日 |
0.2.0 | 2023年3月20日 |
0.1.1 | 2023年3月19日 |
#209 在 值格式化
每月下载96次
6KB
123 行
这是什么?
promformat
是一个小型实用库,用于帮助格式化 Prometheus 指标。
为什么?
在大多数情况下,可以使用 prometheus
crate 简单地暴露 Rust 中的 Prometheus 指标,使用注册为 lazy_static!
的全局计数器或类似技巧。然而,这可能会对某些用例产生潜在的不利影响。
例如,您可能希望根据不同的条件设置和取消设置指标,或注册/注销特定的标签集。在 prometheus
crate 中完成此类任务可能既困难又繁琐。
用法
使用 promformat
非常简单
use promformat::Metrics;
let mut metrics = Metrics::new();
let mut gauge1 = metrics.gauge("gauge_1", "Some gauge help text here");
gauge1.label("label1", "value1").label("label2", "value2").set(100);
let rendered = metrics.render();
许可证
promformat
使用 Apache 2.0 许可证