1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-06-02 22:57:27 +02:00
Krzesimir Nowak 25e97e56a4 move mock tracer to internal/metric (#259)
* export noop meter

* move mock meter to internal/metric package
2019-10-30 12:59:34 -07:00

36 lines
1016 B
Go

// Copyright 2019, OpenTelemetry Authors
//
// 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.
package metric
import (
"sync/atomic"
)
var global atomic.Value
// GlobalMeter returns a meter registered as a global meter. If no
// meter is registered then an instance of noop Meter is returned.
func GlobalMeter() Meter {
if t := global.Load(); t != nil {
return t.(Meter)
}
return NoopMeter{}
}
// SetGlobalMeter sets provided meter as a global meter.
func SetGlobalMeter(t Meter) {
global.Store(t)
}