1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00
opentelemetry-go/metric_test.go
2024-02-29 07:05:28 +01:00

33 lines
759 B
Go

// 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)
}