From a9aaa4e906df02a1ca74047ce2c901bcb44bbfea Mon Sep 17 00:00:00 2001 From: Ian Cottrell Date: Sun, 8 Mar 2020 00:03:39 -0500 Subject: [PATCH] internal/telemetry: use keys properly for benchmarks Change-Id: I571628db26a5b89fd567077d90d325fd76301956 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222598 Run-TryBot: Ian Cottrell TryBot-Result: Gobot Gobot Reviewed-by: Robert Findley --- internal/telemetry/bench_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/internal/telemetry/bench_test.go b/internal/telemetry/bench_test.go index 44e2aa1184..34eab4a3c4 100644 --- a/internal/telemetry/bench_test.go +++ b/internal/telemetry/bench_test.go @@ -18,8 +18,10 @@ type Hooks struct { } var ( + aValue = event.Key("a") + bValue = event.Key("b") aCount = stats.Int64("aCount", "Count of time A is called.", unit.Dimensionless) - aValue = stats.Int64("aValue", "A value.", unit.Dimensionless) + aStat = stats.Int64("aValue", "A value.", unit.Dimensionless) bCount = stats.Int64("B", "Count of time B is called.", unit.Dimensionless) bLength = stats.Int64("BLen", "B length.", unit.Dimensionless) @@ -49,15 +51,15 @@ var ( Log = Hooks{ A: func(ctx context.Context, a *int) (context.Context, func()) { - event.Print(ctx, "start A", event.TagOf("a", *a)) + event.Print(ctx, "start A", aValue.Of(*a)) return ctx, func() { - event.Print(ctx, "end A", event.TagOf("a", *a)) + event.Print(ctx, "end A", aValue.Of(*a)) } }, B: func(ctx context.Context, b *string) (context.Context, func()) { - event.Print(ctx, "start B", event.TagOf("b", *b)) + event.Print(ctx, "start B", bValue.Of(*b)) return ctx, func() { - event.Print(ctx, "end B", event.TagOf("b", *b)) + event.Print(ctx, "end B", bValue.Of(*b)) } }, } @@ -75,7 +77,7 @@ var ( A: func(ctx context.Context, a *int) (context.Context, func()) { aCount.Record(ctx, 1) return ctx, func() { - aValue.Record(ctx, int64(*a)) + aStat.Record(ctx, int64(*a)) } }, B: func(ctx context.Context, b *string) (context.Context, func()) {