Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OTel to v1.0.0-RC3 #29

Merged
merged 3 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added RecordError to SpanOption. (#23)
- Added DisableQuery to SpanOption. (#26)

### Changed

- Upgrade OTel to v1.0.0-RC3. (#29)

## [0.5.0] - 2021-08-02

### Changed
Expand Down
1 change: 0 additions & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
Expand Down
26 changes: 16 additions & 10 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/oteltest"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
"go.opentelemetry.io/otel/trace"
)
Expand Down Expand Up @@ -190,7 +188,7 @@ func TestOtConn_Ping(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
if tc.pingOption {
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in Ping
Expand Down Expand Up @@ -273,7 +271,7 @@ func TestOtConn_ExecContext(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in ExecContext
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down Expand Up @@ -349,7 +347,7 @@ func TestOtConn_QueryContext(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in QueryContext
require.Equal(t, expectedSpanCount, len(spanList))
Expand All @@ -372,8 +370,16 @@ func TestOtConn_QueryContext(t *testing.T) {
require.True(t, ok)
if dummySpan != nil {
assert.Equal(t, dummySpan.SpanContext().TraceID(), otelRows.span.SpanContext().TraceID())
// Span that creates in newRows() is the child of the dummySpan
assert.Equal(t, dummySpan.SpanContext().SpanID(), otelRows.span.(*oteltest.Span).ParentSpanID())

// Get a span from started span list
startedSpanList := sr.Started()
require.Len(t, startedSpanList, expectedSpanCount+1)
span := startedSpanList[expectedSpanCount]
// Make sure this span is the same as the span from otelRows
require.Equal(t, otelRows.span.SpanContext().SpanID(), span.SpanContext().SpanID())

// The span that creates in newRows() is the child of the dummySpan
assert.Equal(t, dummySpan.SpanContext().SpanID(), span.Parent().SpanID())
}
}
})
Expand Down Expand Up @@ -435,7 +441,7 @@ func TestOtConn_PrepareContext(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in PrepareContext
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down Expand Up @@ -505,7 +511,7 @@ func TestOtConn_BeginTx(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in BeginTx
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down Expand Up @@ -577,7 +583,7 @@ func TestOtConn_ResetSession(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in ResetSession
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down
6 changes: 3 additions & 3 deletions example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ replace github.com/XSAM/otelsql => ../
require (
github.com/XSAM/otelsql v0.4.0
github.com/go-sql-driver/mysql v1.5.0
go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC2
go.opentelemetry.io/otel/sdk v1.0.0-RC2
go.opentelemetry.io/otel v1.0.0-RC3
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC3
go.opentelemetry.io/otel/sdk v1.0.0-RC3
)
18 changes: 8 additions & 10 deletions example/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg=
go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC2 h1:crksoFyTPDDywRJDUW36OZma+C3HhcYwQLPUZZMXFO0=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC2/go.mod h1:6kVxj1C/f3irP/IeeZNbcEwbg3rwnM6a7bCrcGbIJeI=
go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk=
go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A=
go.opentelemetry.io/otel/sdk v1.0.0-RC2 h1:ROuteeSCBaZNjiT9JcFzZepmInDvLktR28Y6qKo8bCs=
go.opentelemetry.io/otel/sdk v1.0.0-RC2/go.mod h1:fgwHyiDn4e5k40TD9VX243rOxXR+jzsWBZYA2P5jpEw=
go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w=
go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
go.opentelemetry.io/otel v1.0.0-RC3 h1:kvwiyEkiUT/JaadXzVLI/R1wDO934A7r3Bs2wEe6wqA=
go.opentelemetry.io/otel v1.0.0-RC3/go.mod h1:Ka5j3ua8tZs4Rkq4Ex3hwgBgOchyPVq5S6P2lz//nKQ=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC3 h1:ewSzc2SagdOx0up5xZPigXh1n3SLsNEslc5edHRBVcs=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.0.0-RC3/go.mod h1:Oxmrmpdvm6lM3tkYmHKGWAhi9+9c2rrAEbwSDn0Bvv8=
go.opentelemetry.io/otel/sdk v1.0.0-RC3 h1:iRMkET+EmJUn5mW0hJzygBraXRmrUwzbOtNvTCh/oKs=
go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us=
go.opentelemetry.io/otel/trace v1.0.0-RC3 h1:9F0ayEvlxv8BmNmPbU005WK7hC+7KbOazCPZjNa1yME=
go.opentelemetry.io/otel/trace v1.0.0-RC3/go.mod h1:VUt2TUYd8S2/ZRX09ZDFZQwn2RqfMB5MzO17jBojGxo=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/stretchr/testify v1.7.0
go.opentelemetry.io/otel v1.0.0-RC2
go.opentelemetry.io/otel/oteltest v1.0.0-RC2
go.opentelemetry.io/otel/trace v1.0.0-RC2
go.opentelemetry.io/otel v1.0.0-RC3
go.opentelemetry.io/otel/sdk v1.0.0-RC3
go.opentelemetry.io/otel/trace v1.0.0-RC3
)
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.opentelemetry.io/otel v1.0.0-RC2 h1:SHhxSjB+omnGZPgGlKe+QMp3MyazcOHdQ8qwo89oKbg=
go.opentelemetry.io/otel v1.0.0-RC2/go.mod h1:w1thVQ7qbAy8MHb0IFj8a5Q2QU0l2ksf8u/CN8m3NOM=
go.opentelemetry.io/otel/oteltest v1.0.0-RC2 h1:xNKqMhlZYkASSyvF4JwObZFMq0jhFN3c3SP+2rCzVPk=
go.opentelemetry.io/otel/oteltest v1.0.0-RC2/go.mod h1:kiQ4tw5tAL4JLTbcOYwK1CWI1HkT5aiLzHovgOVnz/A=
go.opentelemetry.io/otel/trace v1.0.0-RC2 h1:dunAP0qDULMIT82atj34m5RgvsIK6LcsXf1c/MsYg1w=
go.opentelemetry.io/otel/trace v1.0.0-RC2/go.mod h1:JPQ+z6nNw9mqEGT8o3eoPTdnNI+Aj5JcxEsVGREIAy4=
go.opentelemetry.io/otel v1.0.0-RC3 h1:kvwiyEkiUT/JaadXzVLI/R1wDO934A7r3Bs2wEe6wqA=
go.opentelemetry.io/otel v1.0.0-RC3/go.mod h1:Ka5j3ua8tZs4Rkq4Ex3hwgBgOchyPVq5S6P2lz//nKQ=
go.opentelemetry.io/otel/sdk v1.0.0-RC3 h1:iRMkET+EmJUn5mW0hJzygBraXRmrUwzbOtNvTCh/oKs=
go.opentelemetry.io/otel/sdk v1.0.0-RC3/go.mod h1:78H6hyg2fka0NYT9fqGuFLvly2yCxiBXDJAgLKo/2Us=
go.opentelemetry.io/otel/trace v1.0.0-RC3 h1:9F0ayEvlxv8BmNmPbU005WK7hC+7KbOazCPZjNa1yME=
go.opentelemetry.io/otel/trace v1.0.0-RC3/go.mod h1:VUt2TUYd8S2/ZRX09ZDFZQwn2RqfMB5MzO17jBojGxo=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
5 changes: 2 additions & 3 deletions option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ import (
"testing"

"github.com/stretchr/testify/assert"

"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/oteltest"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

func TestOptions(t *testing.T) {
tracerProvider := oteltest.NewTracerProvider()
tracerProvider := sdktrace.NewTracerProvider()

testCases := []struct {
name string
Expand Down
24 changes: 15 additions & 9 deletions rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/codes"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)

type mockRows struct {
Expand Down Expand Up @@ -88,20 +88,20 @@ func TestOtRows_Close(t *testing.T) {
// Close
err := rows.Close()

spanList := sr.Completed()
spanList := sr.Ended()
// A span created in newRows()
require.Equal(t, 2, len(spanList))
span := spanList[1]
assert.True(t, span.Ended())
assert.False(t, span.EndTime().IsZero())

assert.Equal(t, 1, mr.closeCount)
if tc.error {
require.Error(t, err)
assert.Equal(t, codes.Error, span.StatusCode())
assert.Equal(t, codes.Error, span.Status().Code)
assert.Len(t, span.Events(), 1)
} else {
require.NoError(t, err)
assert.Equal(t, codes.Unset, span.StatusCode())
assert.Equal(t, codes.Unset, span.Status().Code)
}
})
}
Expand Down Expand Up @@ -144,18 +144,18 @@ func TestOtRows_Next(t *testing.T) {
// A span created in newRows()
require.Equal(t, 2, len(spanList))
span := spanList[1]
assert.False(t, span.Ended())
assert.True(t, span.EndTime().IsZero())

assert.Equal(t, 1, mr.nextCount)
assert.Equal(t, []driver.Value{"test"}, mr.nextDest)
var expectedEventCount int
if tc.error {
require.Error(t, err)
assert.Equal(t, codes.Error, span.StatusCode())
assert.Equal(t, codes.Error, span.Status().Code)
expectedEventCount++
} else {
require.NoError(t, err)
assert.Equal(t, codes.Unset, span.StatusCode())
assert.Equal(t, codes.Unset, span.Status().Code)
}

if tc.rowsNextOption {
Expand Down Expand Up @@ -203,7 +203,13 @@ func TestNewRows(t *testing.T) {
// One dummy span and one span created in newRows()
require.Equal(t, expectedSpanCount, len(spanList))

assertSpanList(t, spanList, spanAssertionParameter{
// Convert []sdktrace.ReadWriteSpan to []sdktrace.ReadOnlySpan explicitly due to the limitation of Go
var readOnlySpanList []sdktrace.ReadOnlySpan
for _, v := range spanList {
readOnlySpanList = append(readOnlySpanList, v)
}

assertSpanList(t, readOnlySpanList, spanAssertionParameter{
parentSpan: dummySpan,
error: false,
expectedAttributes: cfg.Attributes,
Expand Down
1 change: 0 additions & 1 deletion sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
)
Expand Down
5 changes: 2 additions & 3 deletions stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
)
Expand Down Expand Up @@ -129,7 +128,7 @@ func TestOtStmt_ExecContext(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and a span created in tx
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down Expand Up @@ -204,7 +203,7 @@ func TestOtStmt_QueryContext(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and a span created in tx
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down
5 changes: 2 additions & 3 deletions tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.opentelemetry.io/otel/attribute"
)

Expand Down Expand Up @@ -99,7 +98,7 @@ func TestOtTx_Commit(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and one span created in tx
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down Expand Up @@ -162,7 +161,7 @@ func TestOtTx_Rollback(t *testing.T) {
require.NoError(t, err)
}

spanList := sr.Completed()
spanList := sr.Ended()
expectedSpanCount := getExpectedSpanCount(tc.allowRootOption, tc.noParentSpan)
// One dummy span and a span created in tx
require.Equal(t, expectedSpanCount, len(spanList))
Expand Down
Loading