From 5f238225089421842bd3380007caca8cf6d9a265 Mon Sep 17 00:00:00 2001 From: John Howard Date: Tue, 14 Sep 2021 09:52:36 -0700 Subject: [PATCH] Register metrics in benchmark Currently, the metric we record is not registered. This hits the fast-path code of not actually recording the metric, so we miss out on detecting any performance to that main code path. This registers the metrics so we actually trigger `record`. --- stats/benchmark_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stats/benchmark_test.go b/stats/benchmark_test.go index e784b8c4c..fade54f9a 100644 --- a/stats/benchmark_test.go +++ b/stats/benchmark_test.go @@ -109,5 +109,13 @@ func BenchmarkRecord8_8Tags(b *testing.B) { } func makeMeasure() *stats.Int64Measure { - return stats.Int64("m", "test measure", "") + m := stats.Int64("m", "test measure", "") + v := &view.View{ + Measure: m, + Aggregation: view.Sum(), + } + if err := view.Register(v); err != nil { + panic(err.Error()) + } + return m }