Skip to content

Commit

Permalink
contrib/uptrace/bun: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Rodrigo Argüello <rodrigo.arguello@datadoghq.com>
  • Loading branch information
darccio and rarguelloF authored Jul 5, 2024
1 parent cfbd067 commit b0c7672
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contrib/uptrace/bun/bun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ func TestServiceName(t *testing.T) {
)

var n int
// Using WithContext will make the postgres span a child of
// the span inside ctx (parentSpan)
res, err := db.NewSelect().ColumnExpr("1").Exec(ctx, &n)
parentSpan.Finish()
spans := mt.FinishedSpans()

require.NoError(t, err)
rows, _ := res.RowsAffected()
assert.Equal(int64(1), rows)
assert.Equal(2, len(spans))
assert.Len(spans, 2)
assert.Equal(nil, err)
assert.Equal(1, n)
assert.Equal("bun", spans[0].OperationName())
Expand All @@ -110,11 +108,13 @@ func TestServiceName(t *testing.T) {
assert.Equal("fake-http-server", spans[1].Tag(ext.ServiceName))
assert.Equal("uptrace/bun", spans[0].Tag(ext.Component))
assert.Equal(ext.DBSystemOtherSQL, spans[0].Tag(ext.DBSystem))
assert.Equal(spans[0].ParentID(), spans[1].SpanID())
})

t.Run("global", func(t *testing.T) {
prevName := globalconfig.ServiceName()
defer globalconfig.SetServiceName(prevName)
globalconfig.SetServiceName("global-service")
defer globalconfig.SetServiceName("")

assert := assert.New(t)
mt := mocktracer.Start()
Expand Down

0 comments on commit b0c7672

Please sign in to comment.