2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2019-08-02 13:52:55 -07:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2019-10-25 11:38:52 -07:00
|
|
|
package global_test
|
2019-08-02 13:52:55 -07:00
|
|
|
|
|
|
|
import (
|
2019-10-22 13:19:11 -07:00
|
|
|
"testing"
|
2019-08-02 13:52:55 -07:00
|
|
|
|
2019-11-26 12:41:24 +08:00
|
|
|
"go.opentelemetry.io/otel/api/global"
|
2019-11-01 11:40:29 -07:00
|
|
|
"go.opentelemetry.io/otel/api/metric"
|
2019-08-02 13:52:55 -07:00
|
|
|
)
|
|
|
|
|
2020-05-29 13:04:55 -07:00
|
|
|
type testMeterProvider struct{}
|
2019-10-22 13:19:11 -07:00
|
|
|
|
2020-05-29 13:04:55 -07:00
|
|
|
var _ metric.Provider = &testMeterProvider{}
|
2019-10-22 13:19:11 -07:00
|
|
|
|
2020-06-12 09:11:17 -07:00
|
|
|
func (*testMeterProvider) Meter(_ string, _ ...metric.MeterOption) metric.Meter {
|
2020-05-11 20:29:06 -07:00
|
|
|
return metric.Meter{}
|
2019-10-30 23:35:02 -07:00
|
|
|
}
|
|
|
|
|
2020-04-27 16:07:14 -07:00
|
|
|
func TestMultipleGlobalMeterProvider(t *testing.T) {
|
2019-10-30 23:35:02 -07:00
|
|
|
p1 := testMeterProvider{}
|
|
|
|
p2 := metric.NoopProvider{}
|
|
|
|
global.SetMeterProvider(&p1)
|
|
|
|
global.SetMeterProvider(&p2)
|
|
|
|
|
|
|
|
got := global.MeterProvider()
|
|
|
|
want := &p2
|
|
|
|
if got != want {
|
|
|
|
t.Fatalf("Provider: got %p, want %p\n", got, want)
|
|
|
|
}
|
|
|
|
}
|