Skip to content

Commit 1fb5140

Browse files
authored
Update to OTel-Go Metrics API @ v0.35 (#381)
1 parent 0b5a22b commit 1fb5140

File tree

38 files changed

+992
-959
lines changed

38 files changed

+992
-959
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
88

99
## Unreleased
1010

11+
## [1.13.0](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.13.0) - 2022-02-15)
12+
13+
- Updates OTel-Go version dependencies to `[email protected]`, `[email protected]`,
14+
15+
- Note the corresponding metrics API changes are 🛑 [BREAKING]
16+
between releases `v0.35.0` and `v0.36.0`. Because this release
17+
depends on metrics API `v0.35.0` it continues to support the
18+
deprecated APIs. The next minor version of this repository will
19+
update the dependency to `v0.36.0` or later. [#381](https://github.com/lightstep/otel-launcher-go/pull/381)
20+
1121
## [1.12.1](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.12.1) - 2022-02-13)
1222

1323
- Replace a RWMutex with Mutex. [#378](https://github.com/lightstep/otel-launcher-go/pull/378)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12.1
1+
1.13.0

examples/metrics/metrics.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ func main() {
5252
// There are 2 example Gauge instruments (one a Gaussian, one
5353
// a Sine wave), and one Histogram.
5454

55-
c1, _ := meter.SyncInt64().Counter(prefix + "counter")
56-
c2, _ := meter.SyncInt64().UpDownCounter(prefix + "updowncounter")
57-
hist, _ := meter.SyncFloat64().Histogram(prefix + "histogram")
58-
mmsc, _ := meter.SyncFloat64().Histogram(prefix + "mmsc",
55+
c1, _ := meter.Int64Counter(prefix + "counter")
56+
c2, _ := meter.Int64UpDownCounter(prefix + "updowncounter")
57+
hist, _ := meter.Float64Histogram(prefix + "histogram")
58+
mmsc, _ := meter.Float64Histogram(prefix+"mmsc",
5959
instrument.WithDescription(`{
6060
"aggregation": "minmaxsumcount"
6161
}`),
@@ -70,7 +70,7 @@ func main() {
7070
mult *= mult
7171

7272
for i := 0; i < 10000; i++ {
73-
value := math.Abs(mult*(100+rand.NormFloat64()*100))
73+
value := math.Abs(mult * (100 + rand.NormFloat64()*100))
7474
hist.Record(ctx, value)
7575
mmsc.Record(ctx, value)
7676
}
@@ -81,61 +81,61 @@ func main() {
8181

8282
startTime := time.Now()
8383

84-
counterObserver, _ := meter.AsyncInt64().Counter(
85-
prefix + "counterobserver",
86-
)
87-
88-
err := meter.RegisterCallback([]instrument.Asynchronous{counterObserver},
89-
func(ctx context.Context) {
90-
counterObserver.Observe(ctx, int64(time.Since(startTime).Seconds()))
91-
},
84+
_, err := meter.Int64ObservableCounter(
85+
prefix+"counterobserver",
86+
instrument.WithInt64Callback(
87+
func(ctx context.Context, obs instrument.Int64Observer) error {
88+
obs.Observe(int64(time.Since(startTime).Seconds()))
89+
return nil
90+
},
91+
),
9292
)
9393

9494
if err != nil {
9595
fmt.Printf("%v", err)
9696
}
9797

98-
updownCounterObserver, _ := meter.AsyncInt64().UpDownCounter(
99-
prefix + "updowncounterobserver",
100-
)
101-
102-
err = meter.RegisterCallback([]instrument.Asynchronous{updownCounterObserver},
103-
func(ctx context.Context) {
104-
updownCounterObserver.Observe(ctx, -int64(time.Since(startTime).Seconds()))
105-
},
98+
_, err = meter.Int64ObservableUpDownCounter(
99+
prefix+"updowncounterobserver",
100+
instrument.WithInt64Callback(
101+
func(ctx context.Context, obs instrument.Int64Observer) error {
102+
obs.Observe(-int64(time.Since(startTime).Seconds()))
103+
return nil
104+
},
105+
),
106106
)
107107

108108
if err != nil {
109109
fmt.Printf("%v", err)
110110
}
111111

112-
gauge, _ := meter.AsyncInt64().Gauge(
113-
prefix + "gauge",
114-
)
115-
116-
err = meter.RegisterCallback([]instrument.Asynchronous{gauge},
117-
func(ctx context.Context) {
118-
gauge.Observe(ctx, int64(50+rand.NormFloat64()*50))
119-
},
112+
_, err = meter.Int64ObservableGauge(
113+
prefix+"gauge",
114+
instrument.WithInt64Callback(
115+
func(ctx context.Context, obs instrument.Int64Observer) error {
116+
obs.Observe(int64(50 + rand.NormFloat64()*50))
117+
return nil
118+
},
119+
),
120120
)
121121

122122
if err != nil {
123123
fmt.Printf("%v", err)
124124
}
125125

126-
sineWave, _ := meter.AsyncFloat64().Gauge(
127-
prefix + "sine_wave",
128-
)
129-
130-
err = meter.RegisterCallback([]instrument.Asynchronous{sineWave},
131-
func(ctx context.Context) {
132-
secs := float64(time.Now().UnixNano()) / float64(time.Second)
133-
134-
sineWave.Observe(ctx, math.Sin(secs/(50*math.Pi)), attribute.String("period", "fastest"))
135-
sineWave.Observe(ctx, math.Sin(secs/(200*math.Pi)), attribute.String("period", "fast"))
136-
sineWave.Observe(ctx, math.Sin(secs/(1000*math.Pi)), attribute.String("period", "regular"))
137-
sineWave.Observe(ctx, math.Sin(secs/(5000*math.Pi)), attribute.String("period", "slow"))
138-
},
126+
_, err = meter.Float64ObservableGauge(
127+
prefix+"sine_wave",
128+
instrument.WithFloat64Callback(
129+
func(ctx context.Context, obs instrument.Float64Observer) error {
130+
secs := float64(time.Now().UnixNano()) / float64(time.Second)
131+
132+
obs.Observe(math.Sin(secs/(50*math.Pi)), attribute.String("period", "fastest"))
133+
obs.Observe(math.Sin(secs/(200*math.Pi)), attribute.String("period", "fast"))
134+
obs.Observe(math.Sin(secs/(1000*math.Pi)), attribute.String("period", "regular"))
135+
obs.Observe(math.Sin(secs/(5000*math.Pi)), attribute.String("period", "slow"))
136+
return nil
137+
},
138+
),
139139
)
140140

141141
if err != nil {

go.mod

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module github.com/lightstep/otel-launcher-go
33
go 1.18
44

55
require (
6-
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.12.1
7-
github.com/lightstep/otel-launcher-go/pipelines v1.12.1
6+
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.13.0
7+
github.com/lightstep/otel-launcher-go/pipelines v1.13.0
88
github.com/sethvargo/go-envconfig v0.8.3
99
github.com/stretchr/testify v1.8.1
10-
go.opentelemetry.io/otel v1.11.2
11-
go.opentelemetry.io/otel/metric v0.34.0
12-
go.opentelemetry.io/otel/sdk v1.11.2
13-
go.opentelemetry.io/otel/trace v1.11.2
10+
go.opentelemetry.io/otel v1.12.0
11+
go.opentelemetry.io/otel/metric v0.35.0
12+
go.opentelemetry.io/otel/sdk v1.12.0
13+
go.opentelemetry.io/otel/trace v1.12.0
1414
)
1515

1616
require (
@@ -23,32 +23,32 @@ require (
2323
github.com/golang/protobuf v1.5.2 // indirect
2424
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
2525
github.com/lightstep/go-expohisto v1.0.0 // indirect
26-
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.12.1 // indirect
26+
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.13.0 // indirect
2727
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
2828
github.com/pmezard/go-difflib v1.0.0 // indirect
2929
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
30-
github.com/shirou/gopsutil/v3 v3.22.9 // indirect
31-
github.com/tklauser/go-sysconf v0.3.10 // indirect
32-
github.com/tklauser/numcpus v0.4.0 // indirect
30+
github.com/shirou/gopsutil/v3 v3.23.1 // indirect
31+
github.com/tklauser/go-sysconf v0.3.11 // indirect
32+
github.com/tklauser/numcpus v0.6.0 // indirect
3333
github.com/yusufpapurcu/wmi v1.2.2 // indirect
34-
go.opentelemetry.io/contrib/instrumentation/host v0.36.4 // indirect
35-
go.opentelemetry.io/contrib/instrumentation/runtime v0.36.4 // indirect
36-
go.opentelemetry.io/contrib/propagators/b3 v1.12.0 // indirect
37-
go.opentelemetry.io/contrib/propagators/ot v1.12.0 // indirect
38-
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
39-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.34.0 // indirect
40-
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.34.0 // indirect
41-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
42-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
43-
go.opentelemetry.io/otel/sdk/metric v0.34.0 // indirect
34+
go.opentelemetry.io/contrib/instrumentation/host v0.38.0 // indirect
35+
go.opentelemetry.io/contrib/instrumentation/runtime v0.38.0 // indirect
36+
go.opentelemetry.io/contrib/propagators/b3 v1.13.0 // indirect
37+
go.opentelemetry.io/contrib/propagators/ot v1.13.0 // indirect
38+
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.13.0 // indirect
39+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.35.0 // indirect
40+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.35.0 // indirect
41+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.12.0 // indirect
42+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.12.0 // indirect
43+
go.opentelemetry.io/otel/sdk/metric v0.35.0 // indirect
4444
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
4545
go.uber.org/atomic v1.7.0 // indirect
46-
go.uber.org/multierr v1.8.0 // indirect
47-
golang.org/x/net v0.2.0 // indirect
48-
golang.org/x/sys v0.2.0 // indirect
49-
golang.org/x/text v0.4.0 // indirect
50-
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
51-
google.golang.org/grpc v1.51.0 // indirect
46+
go.uber.org/multierr v1.9.0 // indirect
47+
golang.org/x/net v0.4.0 // indirect
48+
golang.org/x/sys v0.4.0 // indirect
49+
golang.org/x/text v0.5.0 // indirect
50+
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
51+
google.golang.org/grpc v1.52.3 // indirect
5252
google.golang.org/protobuf v1.28.1 // indirect
5353
gopkg.in/yaml.v3 v3.0.1 // indirect
5454
)

0 commit comments

Comments
 (0)