Skip to content

Commit

Permalink
Merge pull request moby#5501 from jsternberg/otel-semconv-change
Browse files Browse the repository at this point in the history
detect: use newer semconv for resource and add unit test
  • Loading branch information
tonistiigi authored Nov 14, 2024
2 parents eaf5371 + 323be17 commit 9a33f71
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion util/tracing/detect/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
)

var (
Expand Down
29 changes: 29 additions & 0 deletions util/tracing/detect/resource_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package detect

import (
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel"
)

func TestResource(t *testing.T) {
prevHandler := otel.GetErrorHandler()
t.Cleanup(func() {
otel.SetErrorHandler(prevHandler)
})

var resourceErr error
otel.SetErrorHandler(otel.ErrorHandlerFunc(func(err error) {
resourceErr = err
}))

res := Resource()

// Should not have an empty schema url. Only happens when
// there is a schema conflict.
require.NotEqual(t, "", res.SchemaURL())

// No error should have been invoked.
require.NoError(t, resourceErr)
}
2 changes: 1 addition & 1 deletion util/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"

Expand Down

0 comments on commit 9a33f71

Please sign in to comment.