Skip to content

Commit

Permalink
Update to latest OTel SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jefferbrecht committed Jan 30, 2023
1 parent 6d8594e commit fd985df
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions integration_test/testdata/otlp/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/metric/instrument"
metricsdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
)
Expand Down Expand Up @@ -53,7 +52,7 @@ func main() {
testGaugeMetric(meter, "WORKLOAD.googleapis.com/otlp.test.prefix5")

// Test cumulative metrics
counter, err := meter.SyncFloat64().Counter("otlp.test.cumulative")
counter, err := meter.Float64Counter("otlp.test.cumulative")
if err != nil {
log.Fatal(err)
}
Expand All @@ -64,13 +63,14 @@ func main() {
}

func testGaugeMetric(meter metric.Meter, name string) {
gauge, err := meter.AsyncFloat64().Gauge(name)
gauge, err := meter.Float64ObservableGauge(name)
if err != nil {
log.Fatal(err)
}
err = meter.RegisterCallback([]instrument.Asynchronous{gauge}, func(c context.Context) {
gauge.Observe(c, 5)
})
_, err = meter.RegisterCallback(func(c context.Context, observer metric.Observer) error {
observer.ObserveFloat64(gauge, 5)
return nil
}, gauge)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit fd985df

Please sign in to comment.