[VOL-5051] - Build and deploy voltctl
[VOL-5152]
[VOL-4961]
[VOL-5063]
[VOL-4966]
[VOL-4893]
[VOL-4906]
go.mod
go.sum
vendor/modules.txt
------------------
o Update voltha-lib-go dep to 7.5.3
o Update voltha-protos dep to 5.4.11
o make mod-update
Makefile
makefiles/
o Add more repo:onf-make makefile logic
o make LOCAL_FIX_PERMS=1 mod-update need to work around docker perm problems.
internal/
pkg/
vendor/
---------
o Update copyright ending date to span 2024.
o make mod-update to regenerate vendor/
Change-Id: Ib89fd6a9cc15c7e08b1274b110dd8141832557e9
diff --git a/vendor/go.opentelemetry.io/otel/api/global/doc.go b/vendor/go.opentelemetry.io/otel/api/global/doc.go
new file mode 100644
index 0000000..fce69e9
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/doc.go
@@ -0,0 +1,16 @@
+// Copyright The 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 global provides global providers, propagators and more.
+package global // import "go.opentelemetry.io/otel/api/global"
diff --git a/vendor/go.opentelemetry.io/otel/api/global/handler.go b/vendor/go.opentelemetry.io/otel/api/global/handler.go
new file mode 100644
index 0000000..83f3e52
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/handler.go
@@ -0,0 +1,91 @@
+// Copyright The 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 global
+
+import (
+ "log"
+ "os"
+ "sync"
+ "sync/atomic"
+
+ "go.opentelemetry.io/otel"
+)
+
+var (
+ // globalErrorHandler provides an ErrorHandler that can be used
+ // throughout an OpenTelemetry instrumented project. When a user
+ // specified ErrorHandler is registered (`SetErrorHandler`) all calls to
+ // `Handle` and will be delegated to the registered ErrorHandler.
+ globalErrorHandler = &loggingErrorHandler{
+ l: log.New(os.Stderr, "", log.LstdFlags),
+ }
+
+ // delegateErrorHandlerOnce ensures that a user provided ErrorHandler is
+ // only ever registered once.
+ delegateErrorHandlerOnce sync.Once
+
+ // Comiple time check that loggingErrorHandler implements ErrorHandler.
+ _ otel.ErrorHandler = (*loggingErrorHandler)(nil)
+)
+
+// loggingErrorHandler logs all errors to STDERR.
+type loggingErrorHandler struct {
+ delegate atomic.Value
+
+ l *log.Logger
+}
+
+// setDelegate sets the ErrorHandler delegate if one is not already set.
+func (h *loggingErrorHandler) setDelegate(d otel.ErrorHandler) {
+ if h.delegate.Load() != nil {
+ // Delegate already registered
+ return
+ }
+ h.delegate.Store(d)
+}
+
+// Handle implements otel.ErrorHandler.
+func (h *loggingErrorHandler) Handle(err error) {
+ if d := h.delegate.Load(); d != nil {
+ d.(otel.ErrorHandler).Handle(err)
+ return
+ }
+ h.l.Print(err)
+}
+
+// ErrorHandler returns the global ErrorHandler instance. If no ErrorHandler
+// instance has been set (`SetErrorHandler`), the default ErrorHandler which
+// logs errors to STDERR is returned.
+func ErrorHandler() otel.ErrorHandler {
+ return globalErrorHandler
+}
+
+// SetErrorHandler sets the global ErrorHandler to be h.
+func SetErrorHandler(h otel.ErrorHandler) {
+ delegateErrorHandlerOnce.Do(func() {
+ current := ErrorHandler()
+ if current == h {
+ return
+ }
+ if internalHandler, ok := current.(*loggingErrorHandler); ok {
+ internalHandler.setDelegate(h)
+ }
+ })
+}
+
+// Handle is a convience function for ErrorHandler().Handle(err)
+func Handle(err error) {
+ ErrorHandler().Handle(err)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/internal/meter.go b/vendor/go.opentelemetry.io/otel/api/global/internal/meter.go
new file mode 100644
index 0000000..b45f4c9
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/internal/meter.go
@@ -0,0 +1,347 @@
+// Copyright The 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 internal
+
+import (
+ "context"
+ "sync"
+ "sync/atomic"
+ "unsafe"
+
+ "go.opentelemetry.io/otel/api/metric"
+ "go.opentelemetry.io/otel/api/metric/registry"
+ "go.opentelemetry.io/otel/label"
+)
+
+// This file contains the forwarding implementation of MeterProvider used as
+// the default global instance. Metric events using instruments provided by
+// this implementation are no-ops until the first Meter implementation is set
+// as the global provider.
+//
+// The implementation here uses Mutexes to maintain a list of active Meters in
+// the MeterProvider and Instruments in each Meter, under the assumption that
+// these interfaces are not performance-critical.
+//
+// We have the invariant that setDelegate() will be called before a new
+// MeterProvider implementation is registered as the global provider. Mutexes
+// in the MeterProvider and Meters ensure that each instrument has a delegate
+// before the global provider is set.
+//
+// Bound instrument operations are implemented by delegating to the
+// instrument after it is registered, with a sync.Once initializer to
+// protect against races with Release().
+//
+// Metric uniqueness checking is implemented by calling the exported
+// methods of the api/metric/registry package.
+
+type meterKey struct {
+ Name, Version string
+}
+
+type meterProvider struct {
+ delegate metric.MeterProvider
+
+ // lock protects `delegate` and `meters`.
+ lock sync.Mutex
+
+ // meters maintains a unique entry for every named Meter
+ // that has been registered through the global instance.
+ meters map[meterKey]*meterEntry
+}
+
+type meterImpl struct {
+ delegate unsafe.Pointer // (*metric.MeterImpl)
+
+ lock sync.Mutex
+ syncInsts []*syncImpl
+ asyncInsts []*asyncImpl
+}
+
+type meterEntry struct {
+ unique metric.MeterImpl
+ impl meterImpl
+}
+
+type instrument struct {
+ descriptor metric.Descriptor
+}
+
+type syncImpl struct {
+ delegate unsafe.Pointer // (*metric.SyncImpl)
+
+ instrument
+}
+
+type asyncImpl struct {
+ delegate unsafe.Pointer // (*metric.AsyncImpl)
+
+ instrument
+
+ runner metric.AsyncRunner
+}
+
+// SyncImpler is implemented by all of the sync metric
+// instruments.
+type SyncImpler interface {
+ SyncImpl() metric.SyncImpl
+}
+
+// AsyncImpler is implemented by all of the async
+// metric instruments.
+type AsyncImpler interface {
+ AsyncImpl() metric.AsyncImpl
+}
+
+type syncHandle struct {
+ delegate unsafe.Pointer // (*metric.HandleImpl)
+
+ inst *syncImpl
+ labels []label.KeyValue
+
+ initialize sync.Once
+}
+
+var _ metric.MeterProvider = &meterProvider{}
+var _ metric.MeterImpl = &meterImpl{}
+var _ metric.InstrumentImpl = &syncImpl{}
+var _ metric.BoundSyncImpl = &syncHandle{}
+var _ metric.AsyncImpl = &asyncImpl{}
+
+func (inst *instrument) Descriptor() metric.Descriptor {
+ return inst.descriptor
+}
+
+// MeterProvider interface and delegation
+
+func newMeterProvider() *meterProvider {
+ return &meterProvider{
+ meters: map[meterKey]*meterEntry{},
+ }
+}
+
+func (p *meterProvider) setDelegate(provider metric.MeterProvider) {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ p.delegate = provider
+ for key, entry := range p.meters {
+ entry.impl.setDelegate(key.Name, key.Version, provider)
+ }
+ p.meters = nil
+}
+
+func (p *meterProvider) Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ if p.delegate != nil {
+ return p.delegate.Meter(instrumentationName, opts...)
+ }
+
+ key := meterKey{
+ Name: instrumentationName,
+ Version: metric.NewMeterConfig(opts...).InstrumentationVersion,
+ }
+ entry, ok := p.meters[key]
+ if !ok {
+ entry = &meterEntry{}
+ entry.unique = registry.NewUniqueInstrumentMeterImpl(&entry.impl)
+ p.meters[key] = entry
+
+ }
+ return metric.WrapMeterImpl(entry.unique, key.Name, metric.WithInstrumentationVersion(key.Version))
+}
+
+// Meter interface and delegation
+
+func (m *meterImpl) setDelegate(name, version string, provider metric.MeterProvider) {
+ m.lock.Lock()
+ defer m.lock.Unlock()
+
+ d := new(metric.MeterImpl)
+ *d = provider.Meter(name, metric.WithInstrumentationVersion(version)).MeterImpl()
+ m.delegate = unsafe.Pointer(d)
+
+ for _, inst := range m.syncInsts {
+ inst.setDelegate(*d)
+ }
+ m.syncInsts = nil
+ for _, obs := range m.asyncInsts {
+ obs.setDelegate(*d)
+ }
+ m.asyncInsts = nil
+}
+
+func (m *meterImpl) NewSyncInstrument(desc metric.Descriptor) (metric.SyncImpl, error) {
+ m.lock.Lock()
+ defer m.lock.Unlock()
+
+ if meterPtr := (*metric.MeterImpl)(atomic.LoadPointer(&m.delegate)); meterPtr != nil {
+ return (*meterPtr).NewSyncInstrument(desc)
+ }
+
+ inst := &syncImpl{
+ instrument: instrument{
+ descriptor: desc,
+ },
+ }
+ m.syncInsts = append(m.syncInsts, inst)
+ return inst, nil
+}
+
+// Synchronous delegation
+
+func (inst *syncImpl) setDelegate(d metric.MeterImpl) {
+ implPtr := new(metric.SyncImpl)
+
+ var err error
+ *implPtr, err = d.NewSyncInstrument(inst.descriptor)
+
+ if err != nil {
+ // TODO: There is no standard way to deliver this error to the user.
+ // See https://github.com/open-telemetry/opentelemetry-go/issues/514
+ // Note that the default SDK will not generate any errors yet, this is
+ // only for added safety.
+ panic(err)
+ }
+
+ atomic.StorePointer(&inst.delegate, unsafe.Pointer(implPtr))
+}
+
+func (inst *syncImpl) Implementation() interface{} {
+ if implPtr := (*metric.SyncImpl)(atomic.LoadPointer(&inst.delegate)); implPtr != nil {
+ return (*implPtr).Implementation()
+ }
+ return inst
+}
+
+func (inst *syncImpl) Bind(labels []label.KeyValue) metric.BoundSyncImpl {
+ if implPtr := (*metric.SyncImpl)(atomic.LoadPointer(&inst.delegate)); implPtr != nil {
+ return (*implPtr).Bind(labels)
+ }
+ return &syncHandle{
+ inst: inst,
+ labels: labels,
+ }
+}
+
+func (bound *syncHandle) Unbind() {
+ bound.initialize.Do(func() {})
+
+ implPtr := (*metric.BoundSyncImpl)(atomic.LoadPointer(&bound.delegate))
+
+ if implPtr == nil {
+ return
+ }
+
+ (*implPtr).Unbind()
+}
+
+// Async delegation
+
+func (m *meterImpl) NewAsyncInstrument(
+ desc metric.Descriptor,
+ runner metric.AsyncRunner,
+) (metric.AsyncImpl, error) {
+
+ m.lock.Lock()
+ defer m.lock.Unlock()
+
+ if meterPtr := (*metric.MeterImpl)(atomic.LoadPointer(&m.delegate)); meterPtr != nil {
+ return (*meterPtr).NewAsyncInstrument(desc, runner)
+ }
+
+ inst := &asyncImpl{
+ instrument: instrument{
+ descriptor: desc,
+ },
+ runner: runner,
+ }
+ m.asyncInsts = append(m.asyncInsts, inst)
+ return inst, nil
+}
+
+func (obs *asyncImpl) Implementation() interface{} {
+ if implPtr := (*metric.AsyncImpl)(atomic.LoadPointer(&obs.delegate)); implPtr != nil {
+ return (*implPtr).Implementation()
+ }
+ return obs
+}
+
+func (obs *asyncImpl) setDelegate(d metric.MeterImpl) {
+ implPtr := new(metric.AsyncImpl)
+
+ var err error
+ *implPtr, err = d.NewAsyncInstrument(obs.descriptor, obs.runner)
+
+ if err != nil {
+ // TODO: There is no standard way to deliver this error to the user.
+ // See https://github.com/open-telemetry/opentelemetry-go/issues/514
+ // Note that the default SDK will not generate any errors yet, this is
+ // only for added safety.
+ panic(err)
+ }
+
+ atomic.StorePointer(&obs.delegate, unsafe.Pointer(implPtr))
+}
+
+// Metric updates
+
+func (m *meterImpl) RecordBatch(ctx context.Context, labels []label.KeyValue, measurements ...metric.Measurement) {
+ if delegatePtr := (*metric.MeterImpl)(atomic.LoadPointer(&m.delegate)); delegatePtr != nil {
+ (*delegatePtr).RecordBatch(ctx, labels, measurements...)
+ }
+}
+
+func (inst *syncImpl) RecordOne(ctx context.Context, number metric.Number, labels []label.KeyValue) {
+ if instPtr := (*metric.SyncImpl)(atomic.LoadPointer(&inst.delegate)); instPtr != nil {
+ (*instPtr).RecordOne(ctx, number, labels)
+ }
+}
+
+// Bound instrument initialization
+
+func (bound *syncHandle) RecordOne(ctx context.Context, number metric.Number) {
+ instPtr := (*metric.SyncImpl)(atomic.LoadPointer(&bound.inst.delegate))
+ if instPtr == nil {
+ return
+ }
+ var implPtr *metric.BoundSyncImpl
+ bound.initialize.Do(func() {
+ implPtr = new(metric.BoundSyncImpl)
+ *implPtr = (*instPtr).Bind(bound.labels)
+ atomic.StorePointer(&bound.delegate, unsafe.Pointer(implPtr))
+ })
+ if implPtr == nil {
+ implPtr = (*metric.BoundSyncImpl)(atomic.LoadPointer(&bound.delegate))
+ }
+ // This may still be nil if instrument was created and bound
+ // without a delegate, then the instrument was set to have a
+ // delegate and unbound.
+ if implPtr == nil {
+ return
+ }
+ (*implPtr).RecordOne(ctx, number)
+}
+
+func AtomicFieldOffsets() map[string]uintptr {
+ return map[string]uintptr{
+ "meterProvider.delegate": unsafe.Offsetof(meterProvider{}.delegate),
+ "meterImpl.delegate": unsafe.Offsetof(meterImpl{}.delegate),
+ "syncImpl.delegate": unsafe.Offsetof(syncImpl{}.delegate),
+ "asyncImpl.delegate": unsafe.Offsetof(asyncImpl{}.delegate),
+ "syncHandle.delegate": unsafe.Offsetof(syncHandle{}.delegate),
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/internal/state.go b/vendor/go.opentelemetry.io/otel/api/global/internal/state.go
new file mode 100644
index 0000000..ecdfd75
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/internal/state.go
@@ -0,0 +1,134 @@
+// Copyright The 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 internal
+
+import (
+ "sync"
+ "sync/atomic"
+
+ "go.opentelemetry.io/otel"
+ "go.opentelemetry.io/otel/api/metric"
+ "go.opentelemetry.io/otel/api/trace"
+)
+
+type (
+ tracerProviderHolder struct {
+ tp trace.TracerProvider
+ }
+
+ meterProviderHolder struct {
+ mp metric.MeterProvider
+ }
+
+ propagatorsHolder struct {
+ tm otel.TextMapPropagator
+ }
+)
+
+var (
+ globalTracer = defaultTracerValue()
+ globalMeter = defaultMeterValue()
+ globalPropagators = defaultPropagatorsValue()
+
+ delegateMeterOnce sync.Once
+ delegateTraceOnce sync.Once
+)
+
+// TracerProvider is the internal implementation for global.TracerProvider.
+func TracerProvider() trace.TracerProvider {
+ return globalTracer.Load().(tracerProviderHolder).tp
+}
+
+// SetTracerProvider is the internal implementation for global.SetTracerProvider.
+func SetTracerProvider(tp trace.TracerProvider) {
+ delegateTraceOnce.Do(func() {
+ current := TracerProvider()
+ if current == tp {
+ // Setting the provider to the prior default is nonsense, panic.
+ // Panic is acceptable because we are likely still early in the
+ // process lifetime.
+ panic("invalid TracerProvider, the global instance cannot be reinstalled")
+ } else if def, ok := current.(*tracerProvider); ok {
+ def.setDelegate(tp)
+ }
+
+ })
+ globalTracer.Store(tracerProviderHolder{tp: tp})
+}
+
+// MeterProvider is the internal implementation for global.MeterProvider.
+func MeterProvider() metric.MeterProvider {
+ return globalMeter.Load().(meterProviderHolder).mp
+}
+
+// SetMeterProvider is the internal implementation for global.SetMeterProvider.
+func SetMeterProvider(mp metric.MeterProvider) {
+ delegateMeterOnce.Do(func() {
+ current := MeterProvider()
+
+ if current == mp {
+ // Setting the provider to the prior default is nonsense, panic.
+ // Panic is acceptable because we are likely still early in the
+ // process lifetime.
+ panic("invalid MeterProvider, the global instance cannot be reinstalled")
+ } else if def, ok := current.(*meterProvider); ok {
+ def.setDelegate(mp)
+ }
+ })
+ globalMeter.Store(meterProviderHolder{mp: mp})
+}
+
+// TextMapPropagator is the internal implementation for global.TextMapPropagator.
+func TextMapPropagator() otel.TextMapPropagator {
+ return globalPropagators.Load().(propagatorsHolder).tm
+}
+
+// SetTextMapPropagator is the internal implementation for global.SetTextMapPropagator.
+func SetTextMapPropagator(p otel.TextMapPropagator) {
+ globalPropagators.Store(propagatorsHolder{tm: p})
+}
+
+func defaultTracerValue() *atomic.Value {
+ v := &atomic.Value{}
+ v.Store(tracerProviderHolder{tp: &tracerProvider{}})
+ return v
+}
+
+func defaultMeterValue() *atomic.Value {
+ v := &atomic.Value{}
+ v.Store(meterProviderHolder{mp: newMeterProvider()})
+ return v
+}
+
+func defaultPropagatorsValue() *atomic.Value {
+ v := &atomic.Value{}
+ v.Store(propagatorsHolder{tm: getDefaultTextMapPropagator()})
+ return v
+}
+
+// getDefaultTextMapPropagator returns the default TextMapPropagator,
+// configured with W3C trace and baggage propagation.
+func getDefaultTextMapPropagator() otel.TextMapPropagator {
+ return otel.NewCompositeTextMapPropagator()
+}
+
+// ResetForTest restores the initial global state, for testing purposes.
+func ResetForTest() {
+ globalTracer = defaultTracerValue()
+ globalMeter = defaultMeterValue()
+ globalPropagators = defaultPropagatorsValue()
+ delegateMeterOnce = sync.Once{}
+ delegateTraceOnce = sync.Once{}
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/internal/trace.go b/vendor/go.opentelemetry.io/otel/api/global/internal/trace.go
new file mode 100644
index 0000000..bcd1461
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/internal/trace.go
@@ -0,0 +1,128 @@
+// Copyright The 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 internal
+
+/*
+This file contains the forwarding implementation of the TracerProvider used as
+the default global instance. Prior to initialization of an SDK, Tracers
+returned by the global TracerProvider will provide no-op functionality. This
+means that all Span created prior to initialization are no-op Spans.
+
+Once an SDK has been initialized, all provided no-op Tracers are swapped for
+Tracers provided by the SDK defined TracerProvider. However, any Span started
+prior to this initialization does not change its behavior. Meaning, the Span
+remains a no-op Span.
+
+The implementation to track and swap Tracers locks all new Tracer creation
+until the swap is complete. This assumes that this operation is not
+performance-critical. If that assumption is incorrect, be sure to configure an
+SDK prior to any Tracer creation.
+*/
+
+import (
+ "context"
+ "sync"
+
+ "go.opentelemetry.io/otel/api/trace"
+ "go.opentelemetry.io/otel/internal/trace/noop"
+)
+
+// tracerProvider is a placeholder for a configured SDK TracerProvider.
+//
+// All TracerProvider functionality is forwarded to a delegate once
+// configured.
+type tracerProvider struct {
+ mtx sync.Mutex
+ tracers []*tracer
+
+ delegate trace.TracerProvider
+}
+
+// Compile-time guarantee that tracerProvider implements the TracerProvider
+// interface.
+var _ trace.TracerProvider = &tracerProvider{}
+
+// setDelegate configures p to delegate all TracerProvider functionality to
+// provider.
+//
+// All Tracers provided prior to this function call are switched out to be
+// Tracers provided by provider.
+//
+// Delegation only happens on the first call to this method. All subsequent
+// calls result in no delegation changes.
+func (p *tracerProvider) setDelegate(provider trace.TracerProvider) {
+ if p.delegate != nil {
+ return
+ }
+
+ p.mtx.Lock()
+ defer p.mtx.Unlock()
+
+ p.delegate = provider
+ for _, t := range p.tracers {
+ t.setDelegate(provider)
+ }
+
+ p.tracers = nil
+}
+
+// Tracer implements TracerProvider.
+func (p *tracerProvider) Tracer(name string, opts ...trace.TracerOption) trace.Tracer {
+ p.mtx.Lock()
+ defer p.mtx.Unlock()
+
+ if p.delegate != nil {
+ return p.delegate.Tracer(name)
+ }
+
+ t := &tracer{name: name, opts: opts}
+ p.tracers = append(p.tracers, t)
+ return t
+}
+
+// tracer is a placeholder for a trace.Tracer.
+//
+// All Tracer functionality is forwarded to a delegate once configured.
+// Otherwise, all functionality is forwarded to a NoopTracer.
+type tracer struct {
+ once sync.Once
+ name string
+ opts []trace.TracerOption
+
+ delegate trace.Tracer
+}
+
+// Compile-time guarantee that tracer implements the trace.Tracer interface.
+var _ trace.Tracer = &tracer{}
+
+// setDelegate configures t to delegate all Tracer functionality to Tracers
+// created by provider.
+//
+// All subsequent calls to the Tracer methods will be passed to the delegate.
+//
+// Delegation only happens on the first call to this method. All subsequent
+// calls result in no delegation changes.
+func (t *tracer) setDelegate(provider trace.TracerProvider) {
+ t.once.Do(func() { t.delegate = provider.Tracer(t.name, t.opts...) })
+}
+
+// Start implements trace.Tracer by forwarding the call to t.delegate if
+// set, otherwise it forwards the call to a NoopTracer.
+func (t *tracer) Start(ctx context.Context, name string, opts ...trace.SpanOption) (context.Context, trace.Span) {
+ if t.delegate != nil {
+ return t.delegate.Start(ctx, name, opts...)
+ }
+ return noop.Tracer.Start(ctx, name, opts...)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/metric.go b/vendor/go.opentelemetry.io/otel/api/global/metric.go
new file mode 100644
index 0000000..f1695bb
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/metric.go
@@ -0,0 +1,49 @@
+// Copyright The 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 global
+
+import (
+ "go.opentelemetry.io/otel/api/global/internal"
+ "go.opentelemetry.io/otel/api/metric"
+)
+
+// Meter creates an implementation of the Meter interface from the global
+// MeterProvider. The instrumentationName must be the name of the library
+// providing instrumentation. This name may be the same as the instrumented
+// code only if that code provides built-in instrumentation. If the
+// instrumentationName is empty, then a implementation defined default name
+// will be used instead.
+//
+// This is short for MeterProvider().Meter(name)
+func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
+ return MeterProvider().Meter(instrumentationName, opts...)
+}
+
+// MeterProvider returns the registered global meter provider. If
+// none is registered then a default meter provider is returned that
+// forwards the Meter interface to the first registered Meter.
+//
+// Use the meter provider to create a named meter. E.g.
+// meter := global.MeterProvider().Meter("example.com/foo")
+// or
+// meter := global.Meter("example.com/foo")
+func MeterProvider() metric.MeterProvider {
+ return internal.MeterProvider()
+}
+
+// SetMeterProvider registers `mp` as the global meter provider.
+func SetMeterProvider(mp metric.MeterProvider) {
+ internal.SetMeterProvider(mp)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/propagation.go b/vendor/go.opentelemetry.io/otel/api/global/propagation.go
new file mode 100644
index 0000000..c5f4c2b
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/propagation.go
@@ -0,0 +1,31 @@
+// Copyright The 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 global
+
+import (
+ "go.opentelemetry.io/otel"
+ "go.opentelemetry.io/otel/api/global/internal"
+)
+
+// TextMapPropagator returns the global TextMapPropagator. If none has been
+// set, a No-Op TextMapPropagator is returned.
+func TextMapPropagator() otel.TextMapPropagator {
+ return internal.TextMapPropagator()
+}
+
+// SetTextMapPropagator sets propagator as the global TSetTextMapPropagator.
+func SetTextMapPropagator(propagator otel.TextMapPropagator) {
+ internal.SetTextMapPropagator(propagator)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/global/trace.go b/vendor/go.opentelemetry.io/otel/api/global/trace.go
new file mode 100644
index 0000000..49a7543
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/global/trace.go
@@ -0,0 +1,44 @@
+// Copyright The 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 global
+
+import (
+ "go.opentelemetry.io/otel/api/global/internal"
+ "go.opentelemetry.io/otel/api/trace"
+)
+
+// Tracer creates a named tracer that implements Tracer interface.
+// If the name is an empty string then provider uses default name.
+//
+// This is short for TracerProvider().Tracer(name)
+func Tracer(name string) trace.Tracer {
+ return TracerProvider().Tracer(name)
+}
+
+// TracerProvider returns the registered global trace provider.
+// If none is registered then an instance of NoopTracerProvider is returned.
+//
+// Use the trace provider to create a named tracer. E.g.
+// tracer := global.TracerProvider().Tracer("example.com/foo")
+// or
+// tracer := global.Tracer("example.com/foo")
+func TracerProvider() trace.TracerProvider {
+ return internal.TracerProvider()
+}
+
+// SetTracerProvider registers `tp` as the global trace provider.
+func SetTracerProvider(tp trace.TracerProvider) {
+ internal.SetTracerProvider(tp)
+}