1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-11-24 08:22:25 +02:00

handle err in metric example test (#4462)

* fix type in metric example test

Signed-off-by: Pulak Kanti Bhowmick <pkbhowmick007@gmail.com>

* handle error in metric example test

Signed-off-by: Pulak Kanti Bhowmick <pkbhowmick007@gmail.com>

* update counter example

Signed-off-by: Pulak Kanti Bhowmick <pkbhowmick007@gmail.com>

* handle the err only

Signed-off-by: Pulak Kanti Bhowmick <pkbhowmick007@gmail.com>

---------

Signed-off-by: Pulak Kanti Bhowmick <pkbhowmick007@gmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
This commit is contained in:
Pulak Kanti Bhowmick 2023-08-28 23:23:18 +06:00 committed by GitHub
parent 3c476ce181
commit f172db89a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,10 +76,18 @@ func ExampleMeter_asynchronous_multiple() {
meter := otel.Meter("go.opentelemetry.io/otel/metric#MultiAsyncExample")
// This is just a sample of memory stats to record from the Memstats
heapAlloc, _ := meter.Int64ObservableUpDownCounter("heapAllocs")
gcCount, _ := meter.Int64ObservableCounter("gcCount")
heapAlloc, err := meter.Int64ObservableUpDownCounter("heapAllocs")
if err != nil {
fmt.Println("failed to register updown counter for heapAllocs")
panic(err)
}
gcCount, err := meter.Int64ObservableCounter("gcCount")
if err != nil {
fmt.Println("failed to register counter for gcCount")
panic(err)
}
_, err := meter.RegisterCallback(
_, err = meter.RegisterCallback(
func(_ context.Context, o metric.Observer) error {
memStats := &runtime.MemStats{}
// This call does work