Skip to content

Commit

Permalink
Bump otel dependencies (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm authored Apr 28, 2023
1 parent 0e8867f commit da29b57
Show file tree
Hide file tree
Showing 27 changed files with 261 additions and 295 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ go get go.nhat.io/otelsql

Compatibility

| `otelsql` | `go.opentelemetry.io/otel/trace` | `go.opentelemetry.io/otel/metric` |
|:--------------------------:|:--------------------------------:|:------------------------------------:|
| `v0.9.*` <sup>&nbsp;</sup> | `v1.14.0` ~> `latest` | `v0.37.0` ~> `latest` |
| `v0.8.*` <sup>&nbsp;</sup> | `v1.12.0` ~> `latest` | `v0.35.0` ~> `v0.36.*` |
| `v0.7.*` <sup>&nbsp;</sup> | `v1.11.1` ~> `latest` | `v0.33.0` ~> `v0.34.*` |
| `v0.6.*` <sup>&nbsp;</sup> | `v1.10.0` ~> `latest` | `v0.32.*` |
| `v0.5.*` <sup>&nbsp;</sup> | `v1.10.0` ~> `latest` | `v0.31.*` |
| `v0.4.*` <sup>1</sup> | `v1.9.0` ~> `latest` | `v0.31.*` |
| `v0.3.*` <sup>1</sup> | `v1.7.0` ~> `latest` | `v0.28.0` ~> `v0.30.*` |
| `v0.2.*` <sup>1</sup> | `v1.6.2` ~> `latest` | `v0.28.0` ~> `v0.30.*` |
| `v0.1.*` <sup>1</sup> | `v1.4.1` ~> `latest` | `v0.26.0` ~> `v0.27.*` |
| `otelsql` | `go.opentelemetry.io/otel/trace` | `go.opentelemetry.io/otel/metric` |
|:---------------------------:|:--------------------------------:|:---------------------------------:|
| `v0.10.*` <sup>&nbsp;</sup> | `v1.15.0` ~> `latest` | `v0.38.0` ~> `latest` |
| `v0.9.*` <sup>&nbsp;</sup> | `v1.14.0` ~> `latest` | `v0.37.0` ~> `v0.37.*` |
| `v0.8.*` <sup>&nbsp;</sup> | `v1.12.0` ~> `latest` | `v0.35.0` ~> `v0.36.*` |
| `v0.7.*` <sup>&nbsp;</sup> | `v1.11.1` ~> `latest` | `v0.33.0` ~> `v0.34.*` |
| `v0.6.*` <sup>&nbsp;</sup> | `v1.10.0` ~> `latest` | `v0.32.*` |
| `v0.5.*` <sup>&nbsp;</sup> | `v1.10.0` ~> `latest` | `v0.31.*` |
| `v0.4.*` <sup>1</sup> | `v1.9.0` ~> `latest` | `v0.31.*` |
| `v0.3.*` <sup>1</sup> | `v1.7.0` ~> `latest` | `v0.28.0` ~> `v0.30.*` |
| `v0.2.*` <sup>1</sup> | `v1.6.2` ~> `latest` | `v0.28.0` ~> `v0.30.*` |
| `v0.1.*` <sup>1</sup> | `v1.4.1` ~> `latest` | `v0.26.0` ~> `v0.27.*` |

<sup>1</sup> Old versions were shipped under `github.com/nhatthm/otelsql`. Use `go get github.com/nhatthm/otelsql` instead.

Expand All @@ -75,7 +76,7 @@ import (
"database/sql"

"go.nhat.io/otelsql"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
)

func openDB(dsn string) (*sql.DB, error) {
Expand Down Expand Up @@ -108,7 +109,7 @@ import (
"database/sql"

"go.nhat.io/otelsql"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
)

func openDB(dsn string) (*sql.DB, error) {
Expand Down Expand Up @@ -333,7 +334,7 @@ import (
"go.nhat.io/otelsql"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
)

func openDB(dsn string) (*sql.DB, error) {
Expand Down
6 changes: 3 additions & 3 deletions begin_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"

"go.nhat.io/otelsql/internal/test/oteltest"
)

func BenchmarkBeginStats(b *testing.B) {
meter := metric.NewNoopMeter()
meter := noop.NewMeterProvider().Meter("begin_test")

histogram, err := meter.Float64Histogram("latency_ms")
require.NoError(b, err)
Expand Down
12 changes: 6 additions & 6 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"sync"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/global"
"go.opentelemetry.io/otel/metric/instrument"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
"go.opentelemetry.io/otel/trace"
)

Expand Down Expand Up @@ -136,14 +136,14 @@ func newConnConfig(opts driverOptions) connConfig {
)

latencyMsHistogram, err := meter.Float64Histogram(dbSQLClientLatencyMs,
instrument.WithUnit(unitMilliseconds),
instrument.WithDescription(`The distribution of latencies of various calls in milliseconds`),
metric.WithUnit(unitMilliseconds),
metric.WithDescription(`The distribution of latencies of various calls in milliseconds`),
)
handleErr(err)

callsCounter, err := meter.Int64Counter(dbSQLClientCalls,
instrument.WithUnit(unitDimensionless),
instrument.WithDescription(`The number of various calls of methods`),
metric.WithUnit(unitDimensionless),
metric.WithDescription(`The number of various calls of methods`),
)
handleErr(err)

Expand Down
2 changes: 1 addition & 1 deletion driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
"go.opentelemetry.io/otel/trace"

"go.nhat.io/otelsql"
Expand Down
6 changes: 3 additions & 3 deletions exec_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"

"go.nhat.io/otelsql/internal/test/oteltest"
)

func BenchmarkExecStats(b *testing.B) {
meter := metric.NewNoopMeter()
meter := noop.NewMeterProvider().Meter("exec_test")

histogram, err := meter.Float64Histogram("latency_ms")
require.NoError(b, err)
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/stretchr/testify v1.8.2
github.com/swaggest/assertjson v1.8.1
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.37.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0
go.opentelemetry.io/otel/metric v0.37.0
go.opentelemetry.io/otel/sdk v1.14.0
go.opentelemetry.io/otel/sdk/metric v0.37.0
go.opentelemetry.io/otel/trace v1.14.0
go.opentelemetry.io/otel v1.15.0
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.38.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.0
go.opentelemetry.io/otel/metric v0.38.0
go.opentelemetry.io/otel/sdk v1.15.0
go.opentelemetry.io/otel/sdk/metric v0.38.0
go.opentelemetry.io/otel/trace v1.15.0
)

require (
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FB
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.37.0 h1:S1Y8Wkl44weO903rqc1mCV4Gqbb7Vd+R+qU1yceN7XQ=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.37.0/go.mod h1:6xZwq1h4G4NxtU8PhjJnWSSVMaJ+yaNbjeSXfCYow+M=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 h1:sEL90JjOO/4yhquXl5zTAkLLsZ5+MycAgX99SDsxGc8=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0/go.mod h1:oCslUcizYdpKYyS9e8srZEqM6BB8fq41VJBjLAE6z1w=
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
go.opentelemetry.io/otel/metric v0.37.0/go.mod h1:DmdaHfGt54iV6UKxsV9slj2bBRJcKC1B1uvDLIioc1s=
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
go.opentelemetry.io/otel/sdk/metric v0.37.0 h1:haYBBtZZxiI3ROwSmkZnI+d0+AVzBWeviuYQDeBWosU=
go.opentelemetry.io/otel/sdk/metric v0.37.0/go.mod h1:mO2WV1AZKKwhwHTV3AKOoIEb9LbUaENZDuGUQd+j4A0=
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
go.opentelemetry.io/otel v1.15.0 h1:NIl24d4eiLJPM0vKn4HjLYM+UZf6gSfi9Z+NmCxkWbk=
go.opentelemetry.io/otel v1.15.0/go.mod h1:qfwLEbWhLPk5gyWrne4XnF0lC8wtywbuJbgfAE3zbek=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.38.0 h1:pokZd2GnN4y5OX/jG5u2IesTSZHtgsUF9C6ZOh+Qe64=
go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.38.0/go.mod h1:4g2qsi1geXSyCPu9eGGCiJ171LWGaZhjrOHqD1kPRVg=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.0 h1:asTjhnG46zZSrrLHjrDJznK4lRS4Hjb0iwzU2jidyOA=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.15.0/go.mod h1:rqaqVhQv4wLN9xUy3JFCgDiltfgtQUFkJywQfm4OwhU=
go.opentelemetry.io/otel/metric v0.38.0 h1:vv/Nv/44S3GzMMmeUhaesBKsAenE6xLkTVWL+zuv30w=
go.opentelemetry.io/otel/metric v0.38.0/go.mod h1:uAtxN5hl8aXh5irD8afBtSwQU5Zjg64WWSz6KheZxBg=
go.opentelemetry.io/otel/sdk v1.15.0 h1:jZTCkRRd08nxD6w7rIaZeDNGZGGQstH3SfLQ3ZsKICk=
go.opentelemetry.io/otel/sdk v1.15.0/go.mod h1:XDEMrYWzJ4YlC17i6Luih2lwDw2j6G0PkUfr1ZqE+rQ=
go.opentelemetry.io/otel/sdk/metric v0.38.0 h1:c/6/VZihe+5ink8ERufY1/o1QtnoON+k1YonZF2jYR4=
go.opentelemetry.io/otel/sdk/metric v0.38.0/go.mod h1:tqrguFLaGJ3i+uyG67bzxJgsG6Y2bL6HmAn9V/cVRRo=
go.opentelemetry.io/otel/trace v1.15.0 h1:5Fwje4O2ooOxkfyqI/kJwxWotggDLix4BSAvpE1wlpo=
go.opentelemetry.io/otel/trace v1.15.0/go.mod h1:CUsmE2Ht1CRkvE8OsMESvraoZrrcgD1J2W8GV1ev0Y4=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
11 changes: 7 additions & 4 deletions internal/test/oteltest/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (r *metricReader) Shutdown(ctx context.Context) error {
return err
}

if err := r.exporter.Export(ctx, rm); err != nil {
if err := r.exporter.Export(ctx, &rm); err != nil {
return err
}

Expand All @@ -41,7 +41,7 @@ type metricEncoder struct {
}

func (e *metricEncoder) Encode(v any) error {
resMetrics, ok := v.(metricdata.ResourceMetrics)
resMetrics, ok := v.(*metricdata.ResourceMetrics)
if !ok {
return e.Encoder.Encode(v)
}
Expand All @@ -66,7 +66,10 @@ func (e *metricEncoder) Encode(v any) error {
case metricdata.Sum[float64]:
metrics = append(metrics, metricDataFromSum(scopedMetric.Name, smd, attrs)...)

case metricdata.Histogram:
case metricdata.Histogram[int64]:
metrics = append(metrics, metricDataFromHistogram(scopedMetric.Name, smd, attrs)...)

case metricdata.Histogram[float64]:
metrics = append(metrics, metricDataFromHistogram(scopedMetric.Name, smd, attrs)...)
}
}
Expand Down Expand Up @@ -101,7 +104,7 @@ func metricDataFromSum[N int64 | float64](name string, g metricdata.Sum[N], attr
return result
}

func metricDataFromHistogram(name string, g metricdata.Histogram, attrs []attribute.KeyValue) []metricData {
func metricDataFromHistogram[N int64 | float64](name string, g metricdata.Histogram[N], attrs []attribute.KeyValue) []metricData {
result := make([]metricData, 0, len(g.DataPoints))

for _, dp := range g.DataPoints {
Expand Down
2 changes: 1 addition & 1 deletion internal/test/oteltest/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
metricsdk "go.opentelemetry.io/otel/sdk/metric"
"go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
"go.opentelemetry.io/otel/trace"

testassert "go.nhat.io/otelsql/internal/test/assert"
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
"go.opentelemetry.io/otel/trace"
)

Expand Down
6 changes: 3 additions & 3 deletions ping_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"

"go.nhat.io/otelsql/internal/test/oteltest"
)

func BenchmarkPingStats(b *testing.B) {
meter := metric.NewNoopMeter()
meter := noop.NewMeterProvider().Meter("ping_test")

histogram, err := meter.Float64Histogram("latency_ms")
require.NoError(b, err)
Expand Down
6 changes: 3 additions & 3 deletions prepare_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"

"go.nhat.io/otelsql/internal/test/oteltest"
)

func BenchmarkPrepareStats(b *testing.B) {
meter := metric.NewNoopMeter()
meter := noop.NewMeterProvider().Meter("prepare_test")

histogram, err := meter.Float64Histogram("latency_ms")
require.NoError(b, err)
Expand Down
6 changes: 3 additions & 3 deletions query_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric/noop"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"

"go.nhat.io/otelsql/internal/test/oteltest"
)

func BenchmarkQueryStats(b *testing.B) {
meter := metric.NewNoopMeter()
meter := noop.NewMeterProvider().Meter("query_test")

histogram, err := meter.Float64Histogram("latency_ms")
require.NoError(b, err)
Expand Down
11 changes: 6 additions & 5 deletions recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"time"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
"go.opentelemetry.io/otel/metric"
semconv "go.opentelemetry.io/otel/semconv/v1.18.0"
)

// float64Recorder adds a new value to the list of Histogram's records.
type float64Recorder = func(ctx context.Context, value float64, labels ...attribute.KeyValue)
type float64Recorder = func(ctx context.Context, value float64, opts ...metric.RecordOption)

// int64Counter adds the value to the counter's sum.
type int64Counter = func(ctx context.Context, value int64, labels ...attribute.KeyValue)
type int64Counter = func(ctx context.Context, value int64, opts ...metric.AddOption)

// methodRecorder records metrics about a sql method.
type methodRecorder interface {
Expand Down Expand Up @@ -46,8 +47,8 @@ func (r methodRecorderImpl) Record(ctx context.Context, method string, labels ..
)
}

r.countCalls(ctx, 1, attrs...)
r.recordLatency(ctx, elapsedTime, attrs...)
r.countCalls(ctx, 1, metric.WithAttributes(attrs...))
r.recordLatency(ctx, elapsedTime, metric.WithAttributes(attrs...))
}
}

Expand Down
Loading

0 comments on commit da29b57

Please sign in to comment.