Skip to content

Commit

Permalink
adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Varkeychan Jacob authored and Varkeychan Jacob committed Nov 23, 2023
1 parent 5e4457e commit 074687b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions instrumentation/opentelemetry/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,17 @@ func TestIterate(t *testing.T) {
// service.instance.id is added implicitly in StartSpan so 3 attributes will be present.
assert.Equal(t, 3, numAttrs)
}

func TestLen(t *testing.T) {
sampler := sdktrace.AlwaysSample()
tp := sdktrace.NewTracerProvider(
sdktrace.WithSampler(sampler),
)
otel.SetTracerProvider(tp)
_, s, _ := StartSpan(context.Background(), "test_span", &sdk.SpanOptions{})
s.SetAttribute("k1", "v1")
s.SetAttribute("k2", 200)

// service.instance.id is added implicitly in StartSpan so 3 attributes will be present.
assert.Equal(t, 3, s.GetAttributes().Len())
}

0 comments on commit 074687b

Please sign in to comment.