繁体   English   中英

如何集成测试普罗米修斯指标

[英]How to integration test prometheus metrics

我有一个正在运行的 golang 服务器,它在/debug端点上公开指标。 我想测试在我的测试中达到端点时记录的指标。

如何捕获服务器记录的实际指标并在集成测试中使用它们? 我在 Github 上看到了很多代码示例,但它们都是单元测试。

针对指标端点的 HTTP GET 请求的响应正文(在您的情况下为/debug )将返回指标的纯文本表示,如下所示:

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0

然后,集成测试可以解析度量的纯文本表示,以断言度量的期望值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM