From 7ad9845966a473bda0015f3f2f7a488d17cd24b4 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 10 Jan 2023 16:22:16 -0800 Subject: [PATCH] Fix metric API example_test --- metric/example_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/metric/example_test.go b/metric/example_test.go index 94a264609bf1..bfa8592b7144 100644 --- a/metric/example_test.go +++ b/metric/example_test.go @@ -85,22 +85,21 @@ func ExampleMeter_asynchronous_multiple() { gcCount, _ := meter.Int64ObservableCounter("gcCount") gcPause, _ := meter.Float64Histogram("gcPause") - _, err := meter.RegisterCallback([]instrument.Asynchronous{ - heapAlloc, - gcCount, - }, - func(ctx context.Context) error { + _, err := meter.RegisterCallback( + func(ctx context.Context, o metric.ObservationRecorder) error { memStats := &runtime.MemStats{} // This call does work runtime.ReadMemStats(memStats) - heapAlloc.Observe(ctx, int64(memStats.HeapAlloc)) - gcCount.Observe(ctx, int64(memStats.NumGC)) + o.Int64(heapAlloc, int64(memStats.HeapAlloc)) + o.Int64(gcCount, int64(memStats.NumGC)) // This function synchronously records the pauses computeGCPauses(ctx, gcPause, memStats.PauseNs[:]) return nil }, + heapAlloc, + gcCount, ) if err != nil {