1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

Remove the sync inst from async example (#4019)

Simplify the ExampleMeter_asynchronous_multiple example test to only
include asynchronous instruments. Remove the synchronous histogram.
This commit is contained in:
Tyler Yahn
2023-04-20 16:14:39 -07:00
committed by GitHub
parent c5e2799a63
commit 002444a2e7
+1 -7
View File
@@ -79,10 +79,9 @@ func ExampleMeter_asynchronous_multiple() {
// This is just a sample of memory stats to record from the Memstats
heapAlloc, _ := meter.Int64ObservableUpDownCounter("heapAllocs")
gcCount, _ := meter.Int64ObservableCounter("gcCount")
gcPause, _ := meter.Float64Histogram("gcPause")
_, err := meter.RegisterCallback(
func(ctx context.Context, o metric.Observer) error {
func(_ context.Context, o metric.Observer) error {
memStats := &runtime.MemStats{}
// This call does work
runtime.ReadMemStats(memStats)
@@ -90,8 +89,6 @@ func ExampleMeter_asynchronous_multiple() {
o.ObserveInt64(heapAlloc, int64(memStats.HeapAlloc))
o.ObserveInt64(gcCount, int64(memStats.NumGC))
// This function synchronously records the pauses
computeGCPauses(ctx, gcPause, memStats.PauseNs[:])
return nil
},
heapAlloc,
@@ -102,6 +99,3 @@ func ExampleMeter_asynchronous_multiple() {
panic(err)
}
}
// This is just an example, see the the contrib runtime instrumentation for real implementation.
func computeGCPauses(ctx context.Context, recorder instrument.Float64Histogram, pauseBuff []uint64) {}