mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-10 00:29:12 +02:00
a3ae50d8bc
* Remove globals from exp/streaming * basic example * Build the streaming example * Update README.md for running streaming example * Remove observer package * Move observer to exporter * Fix * Re-run make circle-ci
34 lines
1011 B
Go
34 lines
1011 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 return meter registered with global registry.
|
|
// 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)
|
|
}
|