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

33 lines
759 B
Go
Raw Normal View History

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package otel // import "go.opentelemetry.io/otel"
import (
"testing"
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/metric"
"go.opentelemetry.io/otel/metric/embedded"
"go.opentelemetry.io/otel/metric/noop"
)
type testMeterProvider struct{ embedded.MeterProvider }
var _ metric.MeterProvider = &testMeterProvider{}
func (*testMeterProvider) Meter(_ string, _ ...metric.MeterOption) metric.Meter {
return noop.NewMeterProvider().Meter("")
}
func TestMultipleGlobalMeterProvider(t *testing.T) {
p1 := testMeterProvider{}
p2 := noop.NewMeterProvider()
SetMeterProvider(&p1)
SetMeterProvider(p2)
got := GetMeterProvider()
assert.Equal(t, p2, got)
}