Skip to content

Commit

Permalink
Update to OTel-Go Metrics API @ v0.35 (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacd authored Feb 15, 2023
1 parent 0b5a22b commit 1fb5140
Show file tree
Hide file tree
Showing 38 changed files with 992 additions and 959 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

## [1.13.0](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.13.0) - 2022-02-15)

- Updates OTel-Go version dependencies to `trace@v1.12.0`, `metrics@v0.35.0`,
`contrib-trace@v1.13.0`, `contrib-metrics@v0.38.0`:
- Note the corresponding metrics API changes are 🛑 [BREAKING]
between releases `v0.35.0` and `v0.36.0`. Because this release
depends on metrics API `v0.35.0` it continues to support the
deprecated APIs. The next minor version of this repository will
update the dependency to `v0.36.0` or later. [#381](https://github.com/lightstep/otel-launcher-go/pull/381)

## [1.12.1](https://github.com/lightstep/otel-launcher-go/releases/tag/v1.12.1) - 2022-02-13)

- Replace a RWMutex with Mutex. [#378](https://github.com/lightstep/otel-launcher-go/pull/378)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.1
1.13.0
84 changes: 42 additions & 42 deletions examples/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func main() {
// There are 2 example Gauge instruments (one a Gaussian, one
// a Sine wave), and one Histogram.

c1, _ := meter.SyncInt64().Counter(prefix + "counter")
c2, _ := meter.SyncInt64().UpDownCounter(prefix + "updowncounter")
hist, _ := meter.SyncFloat64().Histogram(prefix + "histogram")
mmsc, _ := meter.SyncFloat64().Histogram(prefix + "mmsc",
c1, _ := meter.Int64Counter(prefix + "counter")
c2, _ := meter.Int64UpDownCounter(prefix + "updowncounter")
hist, _ := meter.Float64Histogram(prefix + "histogram")
mmsc, _ := meter.Float64Histogram(prefix+"mmsc",
instrument.WithDescription(`{
"aggregation": "minmaxsumcount"
}`),
Expand All @@ -70,7 +70,7 @@ func main() {
mult *= mult

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

startTime := time.Now()

counterObserver, _ := meter.AsyncInt64().Counter(
prefix + "counterobserver",
)

err := meter.RegisterCallback([]instrument.Asynchronous{counterObserver},
func(ctx context.Context) {
counterObserver.Observe(ctx, int64(time.Since(startTime).Seconds()))
},
_, err := meter.Int64ObservableCounter(
prefix+"counterobserver",
instrument.WithInt64Callback(
func(ctx context.Context, obs instrument.Int64Observer) error {
obs.Observe(int64(time.Since(startTime).Seconds()))
return nil
},
),
)

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

updownCounterObserver, _ := meter.AsyncInt64().UpDownCounter(
prefix + "updowncounterobserver",
)

err = meter.RegisterCallback([]instrument.Asynchronous{updownCounterObserver},
func(ctx context.Context) {
updownCounterObserver.Observe(ctx, -int64(time.Since(startTime).Seconds()))
},
_, err = meter.Int64ObservableUpDownCounter(
prefix+"updowncounterobserver",
instrument.WithInt64Callback(
func(ctx context.Context, obs instrument.Int64Observer) error {
obs.Observe(-int64(time.Since(startTime).Seconds()))
return nil
},
),
)

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

gauge, _ := meter.AsyncInt64().Gauge(
prefix + "gauge",
)

err = meter.RegisterCallback([]instrument.Asynchronous{gauge},
func(ctx context.Context) {
gauge.Observe(ctx, int64(50+rand.NormFloat64()*50))
},
_, err = meter.Int64ObservableGauge(
prefix+"gauge",
instrument.WithInt64Callback(
func(ctx context.Context, obs instrument.Int64Observer) error {
obs.Observe(int64(50 + rand.NormFloat64()*50))
return nil
},
),
)

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

sineWave, _ := meter.AsyncFloat64().Gauge(
prefix + "sine_wave",
)

err = meter.RegisterCallback([]instrument.Asynchronous{sineWave},
func(ctx context.Context) {
secs := float64(time.Now().UnixNano()) / float64(time.Second)

sineWave.Observe(ctx, math.Sin(secs/(50*math.Pi)), attribute.String("period", "fastest"))
sineWave.Observe(ctx, math.Sin(secs/(200*math.Pi)), attribute.String("period", "fast"))
sineWave.Observe(ctx, math.Sin(secs/(1000*math.Pi)), attribute.String("period", "regular"))
sineWave.Observe(ctx, math.Sin(secs/(5000*math.Pi)), attribute.String("period", "slow"))
},
_, err = meter.Float64ObservableGauge(
prefix+"sine_wave",
instrument.WithFloat64Callback(
func(ctx context.Context, obs instrument.Float64Observer) error {
secs := float64(time.Now().UnixNano()) / float64(time.Second)

obs.Observe(math.Sin(secs/(50*math.Pi)), attribute.String("period", "fastest"))
obs.Observe(math.Sin(secs/(200*math.Pi)), attribute.String("period", "fast"))
obs.Observe(math.Sin(secs/(1000*math.Pi)), attribute.String("period", "regular"))
obs.Observe(math.Sin(secs/(5000*math.Pi)), attribute.String("period", "slow"))
return nil
},
),
)

if err != nil {
Expand Down
52 changes: 26 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/lightstep/otel-launcher-go
go 1.18

require (
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.12.1
github.com/lightstep/otel-launcher-go/pipelines v1.12.1
github.com/lightstep/otel-launcher-go/lightstep/sdk/metric v1.13.0
github.com/lightstep/otel-launcher-go/pipelines v1.13.0
github.com/sethvargo/go-envconfig v0.8.3
github.com/stretchr/testify v1.8.1
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/metric v0.34.0
go.opentelemetry.io/otel/sdk v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
go.opentelemetry.io/otel v1.12.0
go.opentelemetry.io/otel/metric v0.35.0
go.opentelemetry.io/otel/sdk v1.12.0
go.opentelemetry.io/otel/trace v1.12.0
)

require (
Expand All @@ -23,32 +23,32 @@ require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/lightstep/go-expohisto v1.0.0 // indirect
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.12.1 // indirect
github.com/lightstep/otel-launcher-go/lightstep/instrumentation v1.13.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/shirou/gopsutil/v3 v3.22.9 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.1 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.opentelemetry.io/contrib/instrumentation/host v0.36.4 // indirect
go.opentelemetry.io/contrib/instrumentation/runtime v0.36.4 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.12.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.34.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2 // indirect
go.opentelemetry.io/otel/sdk/metric v0.34.0 // indirect
go.opentelemetry.io/contrib/instrumentation/host v0.38.0 // indirect
go.opentelemetry.io/contrib/instrumentation/runtime v0.38.0 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.13.0 // indirect
go.opentelemetry.io/contrib/propagators/ot v1.13.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.13.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.35.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.35.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.12.0 // indirect
go.opentelemetry.io/otel/sdk/metric v0.35.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.51.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.4.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 // indirect
google.golang.org/grpc v1.52.3 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
Loading

0 comments on commit 1fb5140

Please sign in to comment.