Skip to content

Commit 002444a

Browse files
authored
Remove the sync inst from async example (#4019)
Simplify the ExampleMeter_asynchronous_multiple example test to only include asynchronous instruments. Remove the synchronous histogram.
1 parent c5e2799 commit 002444a

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

metric/example_test.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,16 @@ func ExampleMeter_asynchronous_multiple() {
7979
// This is just a sample of memory stats to record from the Memstats
8080
heapAlloc, _ := meter.Int64ObservableUpDownCounter("heapAllocs")
8181
gcCount, _ := meter.Int64ObservableCounter("gcCount")
82-
gcPause, _ := meter.Float64Histogram("gcPause")
8382

8483
_, err := meter.RegisterCallback(
85-
func(ctx context.Context, o metric.Observer) error {
84+
func(_ context.Context, o metric.Observer) error {
8685
memStats := &runtime.MemStats{}
8786
// This call does work
8887
runtime.ReadMemStats(memStats)
8988

9089
o.ObserveInt64(heapAlloc, int64(memStats.HeapAlloc))
9190
o.ObserveInt64(gcCount, int64(memStats.NumGC))
9291

93-
// This function synchronously records the pauses
94-
computeGCPauses(ctx, gcPause, memStats.PauseNs[:])
9592
return nil
9693
},
9794
heapAlloc,
@@ -102,6 +99,3 @@ func ExampleMeter_asynchronous_multiple() {
10299
panic(err)
103100
}
104101
}
105-
106-
// This is just an example, see the the contrib runtime instrumentation for real implementation.
107-
func computeGCPauses(ctx context.Context, recorder instrument.Float64Histogram, pauseBuff []uint64) {}

0 commit comments

Comments
 (0)