-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovider_test.go
32 lines (23 loc) · 900 Bytes
/
provider_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package ddspanname
import (
"context"
"testing"
"github.com/stretchr/testify/require"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.opentelemetry.io/otel/sdk/trace/tracetest"
)
func TestProvider(t *testing.T) {
sr := tracetest.NewSpanRecorder()
tracerProvider := sdktrace.NewTracerProvider(sdktrace.WithSpanProcessor(sr))
ddprovider := NewTracerProvider("ddspanname.operation",
WithTracerProvider(tracerProvider))
ddtracer := ddprovider.Tracer("ddspanname.instrument")
require.IsType(t, &tracer{}, ddtracer)
_, span := ddtracer.Start(context.Background(), "ddspanname.span")
span.End()
spans := sr.Ended()
require.Len(t, spans, 1)
require.Equal(t, "ddspanname.span", spans[0].Name())
require.Contains(t, spans[0].Attributes(), DDOperationNameKey.String("ddspanname.operation"))
require.Contains(t, spans[0].Attributes(), DDResourceNameKey.String("ddspanname.span"))
}