1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-11-28 08:38:51 +02:00
opentelemetry-go/trace_test.go
2024-02-29 07:05:28 +01:00

33 lines
732 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package otel
import (
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
"go.opentelemetry.io/otel/trace/noop"
)
type testTracerProvider struct{ embedded.TracerProvider }
var _ trace.TracerProvider = &testTracerProvider{}
func (*testTracerProvider) Tracer(_ string, _ ...trace.TracerOption) trace.Tracer {
return noop.NewTracerProvider().Tracer("")
}
func TestMultipleGlobalTracerProvider(t *testing.T) {
p1 := testTracerProvider{}
p2 := noop.NewTracerProvider()
SetTracerProvider(&p1)
SetTracerProvider(p2)
got := GetTracerProvider()
assert.Equal(t, p2, got)
}