Skip to content

Commit

Permalink
add test for WithRegistration and WithSDK
Browse files Browse the repository at this point in the history
  • Loading branch information
rghetia committed Mar 6, 2020
1 parent 4e662bb commit 5f3c381
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,53 @@ import (
export "go.opentelemetry.io/otel/sdk/export/trace"
)

func TestNewExporterPipelineWithRegistration(t *testing.T) {
tp, fn, err := NewExportPipeline(
WithCollectorEndpoint("http://localhost:14268/api/traces"),
WithRegistration(),
)
defer fn()
assert.NoError(t, err)
assert.Same(t, tp, global.TraceProvider())
}

func TestNewExporterPipelineWithoutRegistration(t *testing.T) {
tp, fn, err := NewExportPipeline(
WithCollectorEndpoint("http://localhost:14268/api/traces"),
)
defer fn()
assert.NoError(t, err)
assert.NotEqual(t, tp, global.TraceProvider())
}

func TestNewExporterPipelineWithSDK(t *testing.T) {
tp, fn, err := NewExportPipeline(
WithCollectorEndpoint("http://localhost:14268/api/traces"),
WithSDK(&sdktrace.Config{
DefaultSampler: sdktrace.AlwaysSample(),
}),
)
defer fn()
assert.NoError(t, err)
_, span := tp.Tracer("jaeger test").Start(context.Background(), "always-on")
spanCtx := span.SpanContext()
assert.True(t, spanCtx.IsSampled())
span.End()

tp2, fn, err := NewExportPipeline(
WithCollectorEndpoint("http://localhost:14268/api/traces"),
WithSDK(&sdktrace.Config{
DefaultSampler: sdktrace.NeverSample(),
}),
)
defer fn()
assert.NoError(t, err)
_, span2 := tp2.Tracer("jaeger test").Start(context.Background(), "never")
span2Ctx := span2.SpanContext()
assert.False(t, span2Ctx.IsSampled())
span2.End()
}

func TestNewRawExporter(t *testing.T) {
const (
collectorEndpoint = "http://localhost"
Expand Down

0 comments on commit 5f3c381

Please sign in to comment.