我有一個運行在端點上的指標的 golang 服務器/debug。我想測試在我的測試中達到端點時記錄的指標。如何捕獲服務器記錄的實際指標并在集成測試中使用它們?我在 Github 上看到了很多代碼示例,但它們都是單元測試。
1 回答

茅侃侃
TA貢獻1842條經驗 獲得超22個贊
在您的情況下,針對指標端點的 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
然后,集成測試可以解析度量的純文本表示,以斷言度量的期望值。
- 1 回答
- 0 關注
- 127 瀏覽
添加回答
舉報
0/150
提交
取消