Skip to content

Commit

Permalink
opentelemetry: add OTel API test for default resource name (#2123)
Browse files Browse the repository at this point in the history
Adds a new test for the default resource name if one is not provided.
  • Loading branch information
katiehockman committed Jul 27, 2023
1 parent 3eed878 commit 066c0e3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ddtrace/opentelemetry/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ func waitForPayload(ctx context.Context, payloads chan string) (string, error) {
}
}

func TestSpanResourceNameDefault(t *testing.T) {
assert := assert.New(t)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

_, payloads, cleanup := mockTracerProvider(t)
tr := otel.Tracer("")
defer cleanup()

_, sp := tr.Start(ctx, "OperationName")
sp.End()

tracer.Flush()
p, err := waitForPayload(ctx, payloads)
if err != nil {
t.Fatalf(err.Error())
}
assert.Contains(p, `"name":"OperationName"`)
assert.Contains(p, `"resource":"OperationName"`)
}

func TestSpanSetName(t *testing.T) {
assert := assert.New(t)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
Expand Down

0 comments on commit 066c0e3

Please sign in to comment.