1 个不稳定版本
0.1.0 | 2023年12月28日 |
---|
#2472 在 解析器实现
56KB
1.5K SLoC
这是一个 Prometheus 展示文本格式的解析器和打印工具。
有关格式的详细描述,请参见 此处。
使用示例
let path = std::env::args().nth(1).expect("A path to scrape text");
let text = std::fs::read_to_string(path).expect("file read");
let mut scrape = Scrape::parse(&text).expect("valid scrape");
// Add a label to all metrics
scrape.add_label("source", "invalid");
// Remove a label from all metrics
scrape.remove_label("source", "invalid");
// format the scrape in the Prometheus exposition text format
let rendered = format!("{scrape}");
assert_eq!(text, rendered);
依赖项
~1.2–1.7MB
~35K SLoC