You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
480 B
Go
21 lines
480 B
Go
2 years ago
|
package tracetest
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"go.opentelemetry.io/otel"
|
||
|
"go.opentelemetry.io/otel/sdk/trace"
|
||
|
"go.opentelemetry.io/otel/sdk/trace/tracetest"
|
||
|
)
|
||
|
|
||
|
// NewInMemoryExporter returns a new InMemoryExporter
|
||
|
// and sets it as the global for tests.
|
||
|
func NewInMemoryExporter(t *testing.T) *tracetest.InMemoryExporter {
|
||
|
me := tracetest.NewInMemoryExporter()
|
||
|
t.Cleanup(func() {
|
||
|
me.Reset()
|
||
|
})
|
||
|
otel.SetTracerProvider(trace.NewTracerProvider(trace.WithSyncer(me)))
|
||
|
return me
|
||
|
}
|