VOL-5088
v2.12 - update voltha.protos version in all go.mod configs
Change-Id: I6228ad6f1fd521fd3d54218e8dd137a2e6d5016e
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)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/async.go b/vendor/go.opentelemetry.io/otel/api/metric/async.go
new file mode 100644
index 0000000..d0d488d
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/async.go
@@ -0,0 +1,217 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// The file is organized as follows:
+//
+// - Observation type
+// - Three kinds of Observer callback (int64, float64, batch)
+// - Three kinds of Observer result (int64, float64, batch)
+// - Three kinds of Observe() function (int64, float64, batch)
+// - Three kinds of AsyncRunner interface (abstract, single, batch)
+// - Two kinds of Observer constructor (int64, float64)
+// - Two kinds of Observation() function (int64, float64)
+// - Various internals
+
+// Observation is used for reporting an asynchronous batch of metric
+// values. Instances of this type should be created by asynchronous
+// instruments (e.g., Int64ValueObserver.Observation()).
+type Observation struct {
+ // number needs to be aligned for 64-bit atomic operations.
+ number Number
+ instrument AsyncImpl
+}
+
+// Int64ObserverFunc is a type of callback that integral
+// observers run.
+type Int64ObserverFunc func(context.Context, Int64ObserverResult)
+
+// Float64ObserverFunc is a type of callback that floating point
+// observers run.
+type Float64ObserverFunc func(context.Context, Float64ObserverResult)
+
+// BatchObserverFunc is a callback argument for use with any
+// Observer instrument that will be reported as a batch of
+// observations.
+type BatchObserverFunc func(context.Context, BatchObserverResult)
+
+// Int64ObserverResult is passed to an observer callback to capture
+// observations for one asynchronous integer metric instrument.
+type Int64ObserverResult struct {
+ instrument AsyncImpl
+ function func([]label.KeyValue, ...Observation)
+}
+
+// Float64ObserverResult is passed to an observer callback to capture
+// observations for one asynchronous floating point metric instrument.
+type Float64ObserverResult struct {
+ instrument AsyncImpl
+ function func([]label.KeyValue, ...Observation)
+}
+
+// BatchObserverResult is passed to a batch observer callback to
+// capture observations for multiple asynchronous instruments.
+type BatchObserverResult struct {
+ function func([]label.KeyValue, ...Observation)
+}
+
+// Observe captures a single integer value from the associated
+// instrument callback, with the given labels.
+func (ir Int64ObserverResult) Observe(value int64, labels ...label.KeyValue) {
+ ir.function(labels, Observation{
+ instrument: ir.instrument,
+ number: NewInt64Number(value),
+ })
+}
+
+// Observe captures a single floating point value from the associated
+// instrument callback, with the given labels.
+func (fr Float64ObserverResult) Observe(value float64, labels ...label.KeyValue) {
+ fr.function(labels, Observation{
+ instrument: fr.instrument,
+ number: NewFloat64Number(value),
+ })
+}
+
+// Observe captures a multiple observations from the associated batch
+// instrument callback, with the given labels.
+func (br BatchObserverResult) Observe(labels []label.KeyValue, obs ...Observation) {
+ br.function(labels, obs...)
+}
+
+// AsyncRunner is expected to convert into an AsyncSingleRunner or an
+// AsyncBatchRunner. SDKs will encounter an error if the AsyncRunner
+// does not satisfy one of these interfaces.
+type AsyncRunner interface {
+ // AnyRunner() is a non-exported method with no functional use
+ // other than to make this a non-empty interface.
+ AnyRunner()
+}
+
+// AsyncSingleRunner is an interface implemented by single-observer
+// callbacks.
+type AsyncSingleRunner interface {
+ // Run accepts a single instrument and function for capturing
+ // observations of that instrument. Each call to the function
+ // receives one captured observation. (The function accepts
+ // multiple observations so the same implementation can be
+ // used for batch runners.)
+ Run(ctx context.Context, single AsyncImpl, capture func([]label.KeyValue, ...Observation))
+
+ AsyncRunner
+}
+
+// AsyncBatchRunner is an interface implemented by batch-observer
+// callbacks.
+type AsyncBatchRunner interface {
+ // Run accepts a function for capturing observations of
+ // multiple instruments.
+ Run(ctx context.Context, capture func([]label.KeyValue, ...Observation))
+
+ AsyncRunner
+}
+
+var _ AsyncSingleRunner = (*Int64ObserverFunc)(nil)
+var _ AsyncSingleRunner = (*Float64ObserverFunc)(nil)
+var _ AsyncBatchRunner = (*BatchObserverFunc)(nil)
+
+// newInt64AsyncRunner returns a single-observer callback for integer Observer instruments.
+func newInt64AsyncRunner(c Int64ObserverFunc) AsyncSingleRunner {
+ return &c
+}
+
+// newFloat64AsyncRunner returns a single-observer callback for floating point Observer instruments.
+func newFloat64AsyncRunner(c Float64ObserverFunc) AsyncSingleRunner {
+ return &c
+}
+
+// newBatchAsyncRunner returns a batch-observer callback use with multiple Observer instruments.
+func newBatchAsyncRunner(c BatchObserverFunc) AsyncBatchRunner {
+ return &c
+}
+
+// AnyRunner implements AsyncRunner.
+func (*Int64ObserverFunc) AnyRunner() {}
+
+// AnyRunner implements AsyncRunner.
+func (*Float64ObserverFunc) AnyRunner() {}
+
+// AnyRunner implements AsyncRunner.
+func (*BatchObserverFunc) AnyRunner() {}
+
+// Run implements AsyncSingleRunner.
+func (i *Int64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]label.KeyValue, ...Observation)) {
+ (*i)(ctx, Int64ObserverResult{
+ instrument: impl,
+ function: function,
+ })
+}
+
+// Run implements AsyncSingleRunner.
+func (f *Float64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]label.KeyValue, ...Observation)) {
+ (*f)(ctx, Float64ObserverResult{
+ instrument: impl,
+ function: function,
+ })
+}
+
+// Run implements AsyncBatchRunner.
+func (b *BatchObserverFunc) Run(ctx context.Context, function func([]label.KeyValue, ...Observation)) {
+ (*b)(ctx, BatchObserverResult{
+ function: function,
+ })
+}
+
+// wrapInt64ValueObserverInstrument converts an AsyncImpl into Int64ValueObserver.
+func wrapInt64ValueObserverInstrument(asyncInst AsyncImpl, err error) (Int64ValueObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Int64ValueObserver{asyncInstrument: common}, err
+}
+
+// wrapFloat64ValueObserverInstrument converts an AsyncImpl into Float64ValueObserver.
+func wrapFloat64ValueObserverInstrument(asyncInst AsyncImpl, err error) (Float64ValueObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Float64ValueObserver{asyncInstrument: common}, err
+}
+
+// wrapInt64SumObserverInstrument converts an AsyncImpl into Int64SumObserver.
+func wrapInt64SumObserverInstrument(asyncInst AsyncImpl, err error) (Int64SumObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Int64SumObserver{asyncInstrument: common}, err
+}
+
+// wrapFloat64SumObserverInstrument converts an AsyncImpl into Float64SumObserver.
+func wrapFloat64SumObserverInstrument(asyncInst AsyncImpl, err error) (Float64SumObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Float64SumObserver{asyncInstrument: common}, err
+}
+
+// wrapInt64UpDownSumObserverInstrument converts an AsyncImpl into Int64UpDownSumObserver.
+func wrapInt64UpDownSumObserverInstrument(asyncInst AsyncImpl, err error) (Int64UpDownSumObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Int64UpDownSumObserver{asyncInstrument: common}, err
+}
+
+// wrapFloat64UpDownSumObserverInstrument converts an AsyncImpl into Float64UpDownSumObserver.
+func wrapFloat64UpDownSumObserverInstrument(asyncInst AsyncImpl, err error) (Float64UpDownSumObserver, error) {
+ common, err := checkNewAsync(asyncInst, err)
+ return Float64UpDownSumObserver{asyncInstrument: common}, err
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/config.go b/vendor/go.opentelemetry.io/otel/api/metric/config.go
new file mode 100644
index 0000000..3cd8fe8
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/config.go
@@ -0,0 +1,125 @@
+// 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 metric
+
+import "go.opentelemetry.io/otel/unit"
+
+// InstrumentConfig contains options for instrument descriptors.
+type InstrumentConfig struct {
+ // Description describes the instrument in human-readable terms.
+ Description string
+ // Unit describes the measurement unit for a instrument.
+ Unit unit.Unit
+ // InstrumentationName is the name of the library providing
+ // instrumentation.
+ InstrumentationName string
+ // InstrumentationVersion is the version of the library providing
+ // instrumentation.
+ InstrumentationVersion string
+}
+
+// InstrumentOption is an interface for applying instrument options.
+type InstrumentOption interface {
+ // ApplyMeter is used to set a InstrumentOption value of a
+ // InstrumentConfig.
+ ApplyInstrument(*InstrumentConfig)
+}
+
+// NewInstrumentConfig creates a new InstrumentConfig
+// and applies all the given options.
+func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig {
+ var config InstrumentConfig
+ for _, o := range opts {
+ o.ApplyInstrument(&config)
+ }
+ return config
+}
+
+// WithDescription applies provided description.
+func WithDescription(desc string) InstrumentOption {
+ return descriptionOption(desc)
+}
+
+type descriptionOption string
+
+func (d descriptionOption) ApplyInstrument(config *InstrumentConfig) {
+ config.Description = string(d)
+}
+
+// WithUnit applies provided unit.
+func WithUnit(unit unit.Unit) InstrumentOption {
+ return unitOption(unit)
+}
+
+type unitOption unit.Unit
+
+func (u unitOption) ApplyInstrument(config *InstrumentConfig) {
+ config.Unit = unit.Unit(u)
+}
+
+// WithInstrumentationName sets the instrumentation name.
+func WithInstrumentationName(name string) InstrumentOption {
+ return instrumentationNameOption(name)
+}
+
+type instrumentationNameOption string
+
+func (i instrumentationNameOption) ApplyInstrument(config *InstrumentConfig) {
+ config.InstrumentationName = string(i)
+}
+
+// MeterConfig contains options for Meters.
+type MeterConfig struct {
+ // InstrumentationVersion is the version of the library providing
+ // instrumentation.
+ InstrumentationVersion string
+}
+
+// MeterOption is an interface for applying Meter options.
+type MeterOption interface {
+ // ApplyMeter is used to set a MeterOption value of a MeterConfig.
+ ApplyMeter(*MeterConfig)
+}
+
+// NewMeterConfig creates a new MeterConfig and applies
+// all the given options.
+func NewMeterConfig(opts ...MeterOption) MeterConfig {
+ var config MeterConfig
+ for _, o := range opts {
+ o.ApplyMeter(&config)
+ }
+ return config
+}
+
+// Option is an interface for applying Instrument or Meter options.
+type Option interface {
+ InstrumentOption
+ MeterOption
+}
+
+// WithInstrumentationVersion sets the instrumentation version.
+func WithInstrumentationVersion(version string) Option {
+ return instrumentationVersionOption(version)
+}
+
+type instrumentationVersionOption string
+
+func (i instrumentationVersionOption) ApplyMeter(config *MeterConfig) {
+ config.InstrumentationVersion = string(i)
+}
+
+func (i instrumentationVersionOption) ApplyInstrument(config *InstrumentConfig) {
+ config.InstrumentationVersion = string(i)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/counter.go b/vendor/go.opentelemetry.io/otel/api/metric/counter.go
new file mode 100644
index 0000000..c03421d
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/counter.go
@@ -0,0 +1,95 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// Float64Counter is a metric that accumulates float64 values.
+type Float64Counter struct {
+ syncInstrument
+}
+
+// Int64Counter is a metric that accumulates int64 values.
+type Int64Counter struct {
+ syncInstrument
+}
+
+// BoundFloat64Counter is a bound instrument for Float64Counter.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundFloat64Counter struct {
+ syncBoundInstrument
+}
+
+// BoundInt64Counter is a boundInstrument for Int64Counter.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundInt64Counter struct {
+ syncBoundInstrument
+}
+
+// Bind creates a bound instrument for this counter. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Float64Counter) Bind(labels ...label.KeyValue) (h BoundFloat64Counter) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Bind creates a bound instrument for this counter. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Int64Counter) Bind(labels ...label.KeyValue) (h BoundInt64Counter) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Float64Counter) Measurement(value float64) Measurement {
+ return c.float64Measurement(value)
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Int64Counter) Measurement(value int64) Measurement {
+ return c.int64Measurement(value)
+}
+
+// Add adds the value to the counter's sum. The labels should contain
+// the keys and values to be associated with this value.
+func (c Float64Counter) Add(ctx context.Context, value float64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewFloat64Number(value), labels)
+}
+
+// Add adds the value to the counter's sum. The labels should contain
+// the keys and values to be associated with this value.
+func (c Int64Counter) Add(ctx context.Context, value int64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewInt64Number(value), labels)
+}
+
+// Add adds the value to the counter's sum using the labels
+// previously bound to this counter via Bind()
+func (b BoundFloat64Counter) Add(ctx context.Context, value float64) {
+ b.directRecord(ctx, NewFloat64Number(value))
+}
+
+// Add adds the value to the counter's sum using the labels
+// previously bound to this counter via Bind()
+func (b BoundInt64Counter) Add(ctx context.Context, value int64) {
+ b.directRecord(ctx, NewInt64Number(value))
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/descriptor.go b/vendor/go.opentelemetry.io/otel/api/metric/descriptor.go
new file mode 100644
index 0000000..3af55e5
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/descriptor.go
@@ -0,0 +1,77 @@
+// 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 metric
+
+import "go.opentelemetry.io/otel/unit"
+
+// Descriptor contains all the settings that describe an instrument,
+// including its name, metric kind, number kind, and the configurable
+// options.
+type Descriptor struct {
+ name string
+ kind Kind
+ numberKind NumberKind
+ config InstrumentConfig
+}
+
+// NewDescriptor returns a Descriptor with the given contents.
+func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...InstrumentOption) Descriptor {
+ return Descriptor{
+ name: name,
+ kind: mkind,
+ numberKind: nkind,
+ config: NewInstrumentConfig(opts...),
+ }
+}
+
+// Name returns the metric instrument's name.
+func (d Descriptor) Name() string {
+ return d.name
+}
+
+// MetricKind returns the specific kind of instrument.
+func (d Descriptor) MetricKind() Kind {
+ return d.kind
+}
+
+// Description provides a human-readable description of the metric
+// instrument.
+func (d Descriptor) Description() string {
+ return d.config.Description
+}
+
+// Unit describes the units of the metric instrument. Unitless
+// metrics return the empty string.
+func (d Descriptor) Unit() unit.Unit {
+ return d.config.Unit
+}
+
+// NumberKind returns whether this instrument is declared over int64,
+// float64, or uint64 values.
+func (d Descriptor) NumberKind() NumberKind {
+ return d.numberKind
+}
+
+// InstrumentationName returns the name of the library that provided
+// instrumentation for this instrument.
+func (d Descriptor) InstrumentationName() string {
+ return d.config.InstrumentationName
+}
+
+// InstrumentationVersion returns the version of the library that provided
+// instrumentation for this instrument.
+func (d Descriptor) InstrumentationVersion() string {
+ return d.config.InstrumentationVersion
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/doc.go b/vendor/go.opentelemetry.io/otel/api/metric/doc.go
new file mode 100644
index 0000000..48a59c5
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/doc.go
@@ -0,0 +1,50 @@
+// 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 metric provides support for reporting measurements using instruments.
+//
+// Instruments are categorized as below:
+//
+// Synchronous instruments are called by the user with a Context.
+// Asynchronous instruments are called by the SDK during collection.
+//
+// Additive instruments are semantically intended for capturing a sum.
+// Non-additive instruments are intended for capturing a distribution.
+//
+// Additive instruments may be monotonic, in which case they are
+// non-descreasing and naturally define a rate.
+//
+// The synchronous instrument names are:
+//
+// Counter: additive, monotonic
+// UpDownCounter: additive
+// ValueRecorder: non-additive
+//
+// and the asynchronous instruments are:
+//
+// SumObserver: additive, monotonic
+// UpDownSumObserver: additive
+// ValueObserver: non-additive
+//
+// All instruments are provided with support for either float64 or
+// int64 input values.
+//
+// The Meter interface supports allocating new instruments as well as
+// interfaces for recording batches of synchronous measurements or
+// asynchronous observations. To obtain a Meter, use a MeterProvider.
+//
+// The MeterProvider interface supports obtaining a named Meter interface. To
+// obtain a MeterProvider implementation, initialize and configure any
+// compatible SDK.
+package metric // import "go.opentelemetry.io/otel/api/metric"
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/kind.go b/vendor/go.opentelemetry.io/otel/api/metric/kind.go
new file mode 100644
index 0000000..9d4b453
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/kind.go
@@ -0,0 +1,79 @@
+// 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.
+
+//go:generate stringer -type=Kind
+
+package metric
+
+// Kind describes the kind of instrument.
+type Kind int8
+
+const (
+ // ValueRecorderKind indicates a ValueRecorder instrument.
+ ValueRecorderKind Kind = iota
+ // ValueObserverKind indicates an ValueObserver instrument.
+ ValueObserverKind
+
+ // CounterKind indicates a Counter instrument.
+ CounterKind
+ // UpDownCounterKind indicates a UpDownCounter instrument.
+ UpDownCounterKind
+
+ // SumObserverKind indicates a SumObserver instrument.
+ SumObserverKind
+ // UpDownSumObserverKind indicates a UpDownSumObserver instrument.
+ UpDownSumObserverKind
+)
+
+// Synchronous returns whether this is a synchronous kind of instrument.
+func (k Kind) Synchronous() bool {
+ switch k {
+ case CounterKind, UpDownCounterKind, ValueRecorderKind:
+ return true
+ }
+ return false
+}
+
+// Asynchronous returns whether this is an asynchronous kind of instrument.
+func (k Kind) Asynchronous() bool {
+ return !k.Synchronous()
+}
+
+// Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).
+func (k Kind) Adding() bool {
+ switch k {
+ case CounterKind, UpDownCounterKind, SumObserverKind, UpDownSumObserverKind:
+ return true
+ }
+ return false
+}
+
+// Adding returns whether this kind of instrument groups its inputs (as opposed to Adding).
+func (k Kind) Grouping() bool {
+ return !k.Adding()
+}
+
+// Monotonic returns whether this kind of instrument exposes a non-decreasing sum.
+func (k Kind) Monotonic() bool {
+ switch k {
+ case CounterKind, SumObserverKind:
+ return true
+ }
+ return false
+}
+
+// Cumulative returns whether this kind of instrument receives precomputed sums.
+func (k Kind) PrecomputedSum() bool {
+ return k.Adding() && k.Asynchronous()
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/kind_string.go b/vendor/go.opentelemetry.io/otel/api/metric/kind_string.go
new file mode 100644
index 0000000..eb1a0d5
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/kind_string.go
@@ -0,0 +1,28 @@
+// Code generated by "stringer -type=Kind"; DO NOT EDIT.
+
+package metric
+
+import "strconv"
+
+func _() {
+ // An "invalid array index" compiler error signifies that the constant values have changed.
+ // Re-run the stringer command to generate them again.
+ var x [1]struct{}
+ _ = x[ValueRecorderKind-0]
+ _ = x[ValueObserverKind-1]
+ _ = x[CounterKind-2]
+ _ = x[UpDownCounterKind-3]
+ _ = x[SumObserverKind-4]
+ _ = x[UpDownSumObserverKind-5]
+}
+
+const _Kind_name = "ValueRecorderKindValueObserverKindCounterKindUpDownCounterKindSumObserverKindUpDownSumObserverKind"
+
+var _Kind_index = [...]uint8{0, 17, 34, 45, 62, 77, 98}
+
+func (i Kind) String() string {
+ if i < 0 || i >= Kind(len(_Kind_index)-1) {
+ return "Kind(" + strconv.FormatInt(int64(i), 10) + ")"
+ }
+ return _Kind_name[_Kind_index[i]:_Kind_index[i+1]]
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/meter.go b/vendor/go.opentelemetry.io/otel/api/metric/meter.go
new file mode 100644
index 0000000..d174913
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/meter.go
@@ -0,0 +1,320 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// The file is organized as follows:
+//
+// - MeterProvider interface
+// - Meter struct
+// - RecordBatch
+// - BatchObserver
+// - Synchronous instrument constructors (2 x int64,float64)
+// - Asynchronous instrument constructors (1 x int64,float64)
+// - Batch asynchronous constructors (1 x int64,float64)
+// - Internals
+
+// MeterProvider supports named Meter instances.
+type MeterProvider interface {
+ // Meter creates an implementation of the Meter interface.
+ // 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.
+ Meter(instrumentationName string, opts ...MeterOption) Meter
+}
+
+// Meter is the OpenTelemetry metric API, based on a `MeterImpl`
+// implementation and the `Meter` library name.
+//
+// An uninitialized Meter is a no-op implementation.
+type Meter struct {
+ impl MeterImpl
+ name, version string
+}
+
+// RecordBatch atomically records a batch of measurements.
+func (m Meter) RecordBatch(ctx context.Context, ls []label.KeyValue, ms ...Measurement) {
+ if m.impl == nil {
+ return
+ }
+ m.impl.RecordBatch(ctx, ls, ms...)
+}
+
+// NewBatchObserver creates a new BatchObserver that supports
+// making batches of observations for multiple instruments.
+func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver {
+ return BatchObserver{
+ meter: m,
+ runner: newBatchAsyncRunner(callback),
+ }
+}
+
+// NewInt64Counter creates a new integer Counter instrument with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error) {
+ return wrapInt64CounterInstrument(
+ m.newSync(name, CounterKind, Int64NumberKind, options))
+}
+
+// NewFloat64Counter creates a new floating point Counter with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error) {
+ return wrapFloat64CounterInstrument(
+ m.newSync(name, CounterKind, Float64NumberKind, options))
+}
+
+// NewInt64UpDownCounter creates a new integer UpDownCounter instrument with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error) {
+ return wrapInt64UpDownCounterInstrument(
+ m.newSync(name, UpDownCounterKind, Int64NumberKind, options))
+}
+
+// NewFloat64UpDownCounter creates a new floating point UpDownCounter with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error) {
+ return wrapFloat64UpDownCounterInstrument(
+ m.newSync(name, UpDownCounterKind, Float64NumberKind, options))
+}
+
+// NewInt64ValueRecorder creates a new integer ValueRecorder instrument with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewInt64ValueRecorder(name string, opts ...InstrumentOption) (Int64ValueRecorder, error) {
+ return wrapInt64ValueRecorderInstrument(
+ m.newSync(name, ValueRecorderKind, Int64NumberKind, opts))
+}
+
+// NewFloat64ValueRecorder creates a new floating point ValueRecorder with the
+// given name, customized with options. May return an error if the
+// name is invalid (e.g., empty) or improperly registered (e.g.,
+// duplicate registration).
+func (m Meter) NewFloat64ValueRecorder(name string, opts ...InstrumentOption) (Float64ValueRecorder, error) {
+ return wrapFloat64ValueRecorderInstrument(
+ m.newSync(name, ValueRecorderKind, Float64NumberKind, opts))
+}
+
+// NewInt64ValueObserver creates a new integer ValueObserver instrument
+// with the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64ValueObserver, error) {
+ if callback == nil {
+ return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64ValueObserverInstrument(
+ m.newAsync(name, ValueObserverKind, Int64NumberKind, opts,
+ newInt64AsyncRunner(callback)))
+}
+
+// NewFloat64ValueObserver creates a new floating point ValueObserver with
+// the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64ValueObserver, error) {
+ if callback == nil {
+ return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64ValueObserverInstrument(
+ m.newAsync(name, ValueObserverKind, Float64NumberKind, opts,
+ newFloat64AsyncRunner(callback)))
+}
+
+// NewInt64SumObserver creates a new integer SumObserver instrument
+// with the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64SumObserver, error) {
+ if callback == nil {
+ return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64SumObserverInstrument(
+ m.newAsync(name, SumObserverKind, Int64NumberKind, opts,
+ newInt64AsyncRunner(callback)))
+}
+
+// NewFloat64SumObserver creates a new floating point SumObserver with
+// the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64SumObserver, error) {
+ if callback == nil {
+ return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64SumObserverInstrument(
+ m.newAsync(name, SumObserverKind, Float64NumberKind, opts,
+ newFloat64AsyncRunner(callback)))
+}
+
+// NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument
+// with the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownSumObserver, error) {
+ if callback == nil {
+ return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64UpDownSumObserverInstrument(
+ m.newAsync(name, UpDownSumObserverKind, Int64NumberKind, opts,
+ newInt64AsyncRunner(callback)))
+}
+
+// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
+// the given name, running a given callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (m Meter) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownSumObserver, error) {
+ if callback == nil {
+ return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64UpDownSumObserverInstrument(
+ m.newAsync(name, UpDownSumObserverKind, Float64NumberKind, opts,
+ newFloat64AsyncRunner(callback)))
+}
+
+// NewInt64ValueObserver creates a new integer ValueObserver instrument
+// with the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewInt64ValueObserver(name string, opts ...InstrumentOption) (Int64ValueObserver, error) {
+ if b.runner == nil {
+ return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64ValueObserverInstrument(
+ b.meter.newAsync(name, ValueObserverKind, Int64NumberKind, opts, b.runner))
+}
+
+// NewFloat64ValueObserver creates a new floating point ValueObserver with
+// the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewFloat64ValueObserver(name string, opts ...InstrumentOption) (Float64ValueObserver, error) {
+ if b.runner == nil {
+ return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64ValueObserverInstrument(
+ b.meter.newAsync(name, ValueObserverKind, Float64NumberKind, opts,
+ b.runner))
+}
+
+// NewInt64SumObserver creates a new integer SumObserver instrument
+// with the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewInt64SumObserver(name string, opts ...InstrumentOption) (Int64SumObserver, error) {
+ if b.runner == nil {
+ return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64SumObserverInstrument(
+ b.meter.newAsync(name, SumObserverKind, Int64NumberKind, opts, b.runner))
+}
+
+// NewFloat64SumObserver creates a new floating point SumObserver with
+// the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewFloat64SumObserver(name string, opts ...InstrumentOption) (Float64SumObserver, error) {
+ if b.runner == nil {
+ return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64SumObserverInstrument(
+ b.meter.newAsync(name, SumObserverKind, Float64NumberKind, opts,
+ b.runner))
+}
+
+// NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument
+// with the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewInt64UpDownSumObserver(name string, opts ...InstrumentOption) (Int64UpDownSumObserver, error) {
+ if b.runner == nil {
+ return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapInt64UpDownSumObserverInstrument(
+ b.meter.newAsync(name, UpDownSumObserverKind, Int64NumberKind, opts, b.runner))
+}
+
+// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
+// the given name, running in a batch callback, and customized with
+// options. May return an error if the name is invalid (e.g., empty)
+// or improperly registered (e.g., duplicate registration).
+func (b BatchObserver) NewFloat64UpDownSumObserver(name string, opts ...InstrumentOption) (Float64UpDownSumObserver, error) {
+ if b.runner == nil {
+ return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
+ }
+ return wrapFloat64UpDownSumObserverInstrument(
+ b.meter.newAsync(name, UpDownSumObserverKind, Float64NumberKind, opts,
+ b.runner))
+}
+
+// MeterImpl returns the underlying MeterImpl of this Meter.
+func (m Meter) MeterImpl() MeterImpl {
+ return m.impl
+}
+
+// newAsync constructs one new asynchronous instrument.
+func (m Meter) newAsync(
+ name string,
+ mkind Kind,
+ nkind NumberKind,
+ opts []InstrumentOption,
+ runner AsyncRunner,
+) (
+ AsyncImpl,
+ error,
+) {
+ if m.impl == nil {
+ return NoopAsync{}, nil
+ }
+ desc := NewDescriptor(name, mkind, nkind, opts...)
+ desc.config.InstrumentationName = m.name
+ desc.config.InstrumentationVersion = m.version
+ return m.impl.NewAsyncInstrument(desc, runner)
+}
+
+// newSync constructs one new synchronous instrument.
+func (m Meter) newSync(
+ name string,
+ metricKind Kind,
+ numberKind NumberKind,
+ opts []InstrumentOption,
+) (
+ SyncImpl,
+ error,
+) {
+ if m.impl == nil {
+ return NoopSync{}, nil
+ }
+ desc := NewDescriptor(name, metricKind, numberKind, opts...)
+ desc.config.InstrumentationName = m.name
+ desc.config.InstrumentationVersion = m.version
+ return m.impl.NewSyncInstrument(desc)
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/must.go b/vendor/go.opentelemetry.io/otel/api/metric/must.go
new file mode 100644
index 0000000..c88e050
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/must.go
@@ -0,0 +1,222 @@
+// 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 metric
+
+// MeterMust is a wrapper for Meter interfaces that panics when any
+// instrument constructor encounters an error.
+type MeterMust struct {
+ meter Meter
+}
+
+// BatchObserverMust is a wrapper for BatchObserver that panics when
+// any instrument constructor encounters an error.
+type BatchObserverMust struct {
+ batch BatchObserver
+}
+
+// Must constructs a MeterMust implementation from a Meter, allowing
+// the application to panic when any instrument constructor yields an
+// error.
+func Must(meter Meter) MeterMust {
+ return MeterMust{meter: meter}
+}
+
+// NewInt64Counter calls `Meter.NewInt64Counter` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64Counter(name string, cos ...InstrumentOption) Int64Counter {
+ if inst, err := mm.meter.NewInt64Counter(name, cos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64Counter calls `Meter.NewFloat64Counter` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64Counter(name string, cos ...InstrumentOption) Float64Counter {
+ if inst, err := mm.meter.NewFloat64Counter(name, cos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64UpDownCounter calls `Meter.NewInt64UpDownCounter` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64UpDownCounter(name string, cos ...InstrumentOption) Int64UpDownCounter {
+ if inst, err := mm.meter.NewInt64UpDownCounter(name, cos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64UpDownCounter calls `Meter.NewFloat64UpDownCounter` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64UpDownCounter(name string, cos ...InstrumentOption) Float64UpDownCounter {
+ if inst, err := mm.meter.NewFloat64UpDownCounter(name, cos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64ValueRecorder calls `Meter.NewInt64ValueRecorder` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64ValueRecorder(name string, mos ...InstrumentOption) Int64ValueRecorder {
+ if inst, err := mm.meter.NewInt64ValueRecorder(name, mos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64ValueRecorder calls `Meter.NewFloat64ValueRecorder` and returns the
+// instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64ValueRecorder(name string, mos ...InstrumentOption) Float64ValueRecorder {
+ if inst, err := mm.meter.NewFloat64ValueRecorder(name, mos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64ValueObserver calls `Meter.NewInt64ValueObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64ValueObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64ValueObserver {
+ if inst, err := mm.meter.NewInt64ValueObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64ValueObserver calls `Meter.NewFloat64ValueObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64ValueObserver {
+ if inst, err := mm.meter.NewFloat64ValueObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64SumObserver calls `Meter.NewInt64SumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64SumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64SumObserver {
+ if inst, err := mm.meter.NewInt64SumObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64SumObserver calls `Meter.NewFloat64SumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64SumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64SumObserver {
+ if inst, err := mm.meter.NewFloat64SumObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64UpDownSumObserver calls `Meter.NewInt64UpDownSumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownSumObserver {
+ if inst, err := mm.meter.NewInt64UpDownSumObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64UpDownSumObserver calls `Meter.NewFloat64UpDownSumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (mm MeterMust) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownSumObserver {
+ if inst, err := mm.meter.NewFloat64UpDownSumObserver(name, callback, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewBatchObserver returns a wrapper around BatchObserver that panics
+// when any instrument constructor returns an error.
+func (mm MeterMust) NewBatchObserver(callback BatchObserverFunc) BatchObserverMust {
+ return BatchObserverMust{
+ batch: mm.meter.NewBatchObserver(callback),
+ }
+}
+
+// NewInt64ValueObserver calls `BatchObserver.NewInt64ValueObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewInt64ValueObserver(name string, oos ...InstrumentOption) Int64ValueObserver {
+ if inst, err := bm.batch.NewInt64ValueObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64ValueObserver calls `BatchObserver.NewFloat64ValueObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewFloat64ValueObserver(name string, oos ...InstrumentOption) Float64ValueObserver {
+ if inst, err := bm.batch.NewFloat64ValueObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64SumObserver calls `BatchObserver.NewInt64SumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewInt64SumObserver(name string, oos ...InstrumentOption) Int64SumObserver {
+ if inst, err := bm.batch.NewInt64SumObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64SumObserver calls `BatchObserver.NewFloat64SumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewFloat64SumObserver(name string, oos ...InstrumentOption) Float64SumObserver {
+ if inst, err := bm.batch.NewFloat64SumObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewInt64UpDownSumObserver calls `BatchObserver.NewInt64UpDownSumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewInt64UpDownSumObserver(name string, oos ...InstrumentOption) Int64UpDownSumObserver {
+ if inst, err := bm.batch.NewInt64UpDownSumObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
+
+// NewFloat64UpDownSumObserver calls `BatchObserver.NewFloat64UpDownSumObserver` and
+// returns the instrument, panicking if it encounters an error.
+func (bm BatchObserverMust) NewFloat64UpDownSumObserver(name string, oos ...InstrumentOption) Float64UpDownSumObserver {
+ if inst, err := bm.batch.NewFloat64UpDownSumObserver(name, oos...); err != nil {
+ panic(err)
+ } else {
+ return inst
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/noop.go b/vendor/go.opentelemetry.io/otel/api/metric/noop.go
new file mode 100644
index 0000000..97867d9
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/noop.go
@@ -0,0 +1,58 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+type NoopMeterProvider struct{}
+
+type noopInstrument struct{}
+type noopBoundInstrument struct{}
+type NoopSync struct{ noopInstrument }
+type NoopAsync struct{ noopInstrument }
+
+var _ MeterProvider = NoopMeterProvider{}
+var _ SyncImpl = NoopSync{}
+var _ BoundSyncImpl = noopBoundInstrument{}
+var _ AsyncImpl = NoopAsync{}
+
+func (NoopMeterProvider) Meter(_ string, _ ...MeterOption) Meter {
+ return Meter{}
+}
+
+func (noopInstrument) Implementation() interface{} {
+ return nil
+}
+
+func (noopInstrument) Descriptor() Descriptor {
+ return Descriptor{}
+}
+
+func (noopBoundInstrument) RecordOne(context.Context, Number) {
+}
+
+func (noopBoundInstrument) Unbind() {
+}
+
+func (NoopSync) Bind([]label.KeyValue) BoundSyncImpl {
+ return noopBoundInstrument{}
+}
+
+func (NoopSync) RecordOne(context.Context, Number, []label.KeyValue) {
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/number.go b/vendor/go.opentelemetry.io/otel/api/metric/number.go
new file mode 100644
index 0000000..c3ca0ed
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/number.go
@@ -0,0 +1,540 @@
+// 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 metric
+
+//go:generate stringer -type=NumberKind
+
+import (
+ "fmt"
+ "math"
+ "sync/atomic"
+
+ "go.opentelemetry.io/otel/internal"
+)
+
+// NumberKind describes the data type of the Number.
+type NumberKind int8
+
+const (
+ // Int64NumberKind means that the Number stores int64.
+ Int64NumberKind NumberKind = iota
+ // Float64NumberKind means that the Number stores float64.
+ Float64NumberKind
+)
+
+// Zero returns a zero value for a given NumberKind
+func (k NumberKind) Zero() Number {
+ switch k {
+ case Int64NumberKind:
+ return NewInt64Number(0)
+ case Float64NumberKind:
+ return NewFloat64Number(0.)
+ default:
+ return Number(0)
+ }
+}
+
+// Minimum returns the minimum representable value
+// for a given NumberKind
+func (k NumberKind) Minimum() Number {
+ switch k {
+ case Int64NumberKind:
+ return NewInt64Number(math.MinInt64)
+ case Float64NumberKind:
+ return NewFloat64Number(-1. * math.MaxFloat64)
+ default:
+ return Number(0)
+ }
+}
+
+// Maximum returns the maximum representable value
+// for a given NumberKind
+func (k NumberKind) Maximum() Number {
+ switch k {
+ case Int64NumberKind:
+ return NewInt64Number(math.MaxInt64)
+ case Float64NumberKind:
+ return NewFloat64Number(math.MaxFloat64)
+ default:
+ return Number(0)
+ }
+}
+
+// Number represents either an integral or a floating point value. It
+// needs to be accompanied with a source of NumberKind that describes
+// the actual type of the value stored within Number.
+type Number uint64
+
+// - constructors
+
+// NewNumberFromRaw creates a new Number from a raw value.
+func NewNumberFromRaw(r uint64) Number {
+ return Number(r)
+}
+
+// NewInt64Number creates an integral Number.
+func NewInt64Number(i int64) Number {
+ return NewNumberFromRaw(internal.Int64ToRaw(i))
+}
+
+// NewFloat64Number creates a floating point Number.
+func NewFloat64Number(f float64) Number {
+ return NewNumberFromRaw(internal.Float64ToRaw(f))
+}
+
+// NewNumberSignChange returns a number with the same magnitude and
+// the opposite sign. `kind` must describe the kind of number in `nn`.
+//
+// Does not change Uint64NumberKind values.
+func NewNumberSignChange(kind NumberKind, nn Number) Number {
+ switch kind {
+ case Int64NumberKind:
+ return NewInt64Number(-nn.AsInt64())
+ case Float64NumberKind:
+ return NewFloat64Number(-nn.AsFloat64())
+ }
+ return nn
+}
+
+// - as x
+
+// AsNumber gets the Number.
+func (n *Number) AsNumber() Number {
+ return *n
+}
+
+// AsRaw gets the uninterpreted raw value. Might be useful for some
+// atomic operations.
+func (n *Number) AsRaw() uint64 {
+ return uint64(*n)
+}
+
+// AsInt64 assumes that the value contains an int64 and returns it as
+// such.
+func (n *Number) AsInt64() int64 {
+ return internal.RawToInt64(n.AsRaw())
+}
+
+// AsFloat64 assumes that the measurement value contains a float64 and
+// returns it as such.
+func (n *Number) AsFloat64() float64 {
+ return internal.RawToFloat64(n.AsRaw())
+}
+
+// - as x atomic
+
+// AsNumberAtomic gets the Number atomically.
+func (n *Number) AsNumberAtomic() Number {
+ return NewNumberFromRaw(n.AsRawAtomic())
+}
+
+// AsRawAtomic gets the uninterpreted raw value atomically. Might be
+// useful for some atomic operations.
+func (n *Number) AsRawAtomic() uint64 {
+ return atomic.LoadUint64(n.AsRawPtr())
+}
+
+// AsInt64Atomic assumes that the number contains an int64 and returns
+// it as such atomically.
+func (n *Number) AsInt64Atomic() int64 {
+ return atomic.LoadInt64(n.AsInt64Ptr())
+}
+
+// AsFloat64Atomic assumes that the measurement value contains a
+// float64 and returns it as such atomically.
+func (n *Number) AsFloat64Atomic() float64 {
+ return internal.RawToFloat64(n.AsRawAtomic())
+}
+
+// - as x ptr
+
+// AsRawPtr gets the pointer to the raw, uninterpreted raw
+// value. Might be useful for some atomic operations.
+func (n *Number) AsRawPtr() *uint64 {
+ return (*uint64)(n)
+}
+
+// AsInt64Ptr assumes that the number contains an int64 and returns a
+// pointer to it.
+func (n *Number) AsInt64Ptr() *int64 {
+ return internal.RawPtrToInt64Ptr(n.AsRawPtr())
+}
+
+// AsFloat64Ptr assumes that the number contains a float64 and returns a
+// pointer to it.
+func (n *Number) AsFloat64Ptr() *float64 {
+ return internal.RawPtrToFloat64Ptr(n.AsRawPtr())
+}
+
+// - coerce
+
+// CoerceToInt64 casts the number to int64. May result in
+// data/precision loss.
+func (n *Number) CoerceToInt64(kind NumberKind) int64 {
+ switch kind {
+ case Int64NumberKind:
+ return n.AsInt64()
+ case Float64NumberKind:
+ return int64(n.AsFloat64())
+ default:
+ // you get what you deserve
+ return 0
+ }
+}
+
+// CoerceToFloat64 casts the number to float64. May result in
+// data/precision loss.
+func (n *Number) CoerceToFloat64(kind NumberKind) float64 {
+ switch kind {
+ case Int64NumberKind:
+ return float64(n.AsInt64())
+ case Float64NumberKind:
+ return n.AsFloat64()
+ default:
+ // you get what you deserve
+ return 0
+ }
+}
+
+// - set
+
+// SetNumber sets the number to the passed number. Both should be of
+// the same kind.
+func (n *Number) SetNumber(nn Number) {
+ *n.AsRawPtr() = nn.AsRaw()
+}
+
+// SetRaw sets the number to the passed raw value. Both number and the
+// raw number should represent the same kind.
+func (n *Number) SetRaw(r uint64) {
+ *n.AsRawPtr() = r
+}
+
+// SetInt64 assumes that the number contains an int64 and sets it to
+// the passed value.
+func (n *Number) SetInt64(i int64) {
+ *n.AsInt64Ptr() = i
+}
+
+// SetFloat64 assumes that the number contains a float64 and sets it
+// to the passed value.
+func (n *Number) SetFloat64(f float64) {
+ *n.AsFloat64Ptr() = f
+}
+
+// - set atomic
+
+// SetNumberAtomic sets the number to the passed number
+// atomically. Both should be of the same kind.
+func (n *Number) SetNumberAtomic(nn Number) {
+ atomic.StoreUint64(n.AsRawPtr(), nn.AsRaw())
+}
+
+// SetRawAtomic sets the number to the passed raw value
+// atomically. Both number and the raw number should represent the
+// same kind.
+func (n *Number) SetRawAtomic(r uint64) {
+ atomic.StoreUint64(n.AsRawPtr(), r)
+}
+
+// SetInt64Atomic assumes that the number contains an int64 and sets
+// it to the passed value atomically.
+func (n *Number) SetInt64Atomic(i int64) {
+ atomic.StoreInt64(n.AsInt64Ptr(), i)
+}
+
+// SetFloat64Atomic assumes that the number contains a float64 and
+// sets it to the passed value atomically.
+func (n *Number) SetFloat64Atomic(f float64) {
+ atomic.StoreUint64(n.AsRawPtr(), internal.Float64ToRaw(f))
+}
+
+// - swap
+
+// SwapNumber sets the number to the passed number and returns the old
+// number. Both this number and the passed number should be of the
+// same kind.
+func (n *Number) SwapNumber(nn Number) Number {
+ old := *n
+ n.SetNumber(nn)
+ return old
+}
+
+// SwapRaw sets the number to the passed raw value and returns the old
+// raw value. Both number and the raw number should represent the same
+// kind.
+func (n *Number) SwapRaw(r uint64) uint64 {
+ old := n.AsRaw()
+ n.SetRaw(r)
+ return old
+}
+
+// SwapInt64 assumes that the number contains an int64, sets it to the
+// passed value and returns the old int64 value.
+func (n *Number) SwapInt64(i int64) int64 {
+ old := n.AsInt64()
+ n.SetInt64(i)
+ return old
+}
+
+// SwapFloat64 assumes that the number contains an float64, sets it to
+// the passed value and returns the old float64 value.
+func (n *Number) SwapFloat64(f float64) float64 {
+ old := n.AsFloat64()
+ n.SetFloat64(f)
+ return old
+}
+
+// - swap atomic
+
+// SwapNumberAtomic sets the number to the passed number and returns
+// the old number atomically. Both this number and the passed number
+// should be of the same kind.
+func (n *Number) SwapNumberAtomic(nn Number) Number {
+ return NewNumberFromRaw(atomic.SwapUint64(n.AsRawPtr(), nn.AsRaw()))
+}
+
+// SwapRawAtomic sets the number to the passed raw value and returns
+// the old raw value atomically. Both number and the raw number should
+// represent the same kind.
+func (n *Number) SwapRawAtomic(r uint64) uint64 {
+ return atomic.SwapUint64(n.AsRawPtr(), r)
+}
+
+// SwapInt64Atomic assumes that the number contains an int64, sets it
+// to the passed value and returns the old int64 value atomically.
+func (n *Number) SwapInt64Atomic(i int64) int64 {
+ return atomic.SwapInt64(n.AsInt64Ptr(), i)
+}
+
+// SwapFloat64Atomic assumes that the number contains an float64, sets
+// it to the passed value and returns the old float64 value
+// atomically.
+func (n *Number) SwapFloat64Atomic(f float64) float64 {
+ return internal.RawToFloat64(atomic.SwapUint64(n.AsRawPtr(), internal.Float64ToRaw(f)))
+}
+
+// - add
+
+// AddNumber assumes that this and the passed number are of the passed
+// kind and adds the passed number to this number.
+func (n *Number) AddNumber(kind NumberKind, nn Number) {
+ switch kind {
+ case Int64NumberKind:
+ n.AddInt64(nn.AsInt64())
+ case Float64NumberKind:
+ n.AddFloat64(nn.AsFloat64())
+ }
+}
+
+// AddRaw assumes that this number and the passed raw value are of the
+// passed kind and adds the passed raw value to this number.
+func (n *Number) AddRaw(kind NumberKind, r uint64) {
+ n.AddNumber(kind, NewNumberFromRaw(r))
+}
+
+// AddInt64 assumes that the number contains an int64 and adds the
+// passed int64 to it.
+func (n *Number) AddInt64(i int64) {
+ *n.AsInt64Ptr() += i
+}
+
+// AddFloat64 assumes that the number contains a float64 and adds the
+// passed float64 to it.
+func (n *Number) AddFloat64(f float64) {
+ *n.AsFloat64Ptr() += f
+}
+
+// - add atomic
+
+// AddNumberAtomic assumes that this and the passed number are of the
+// passed kind and adds the passed number to this number atomically.
+func (n *Number) AddNumberAtomic(kind NumberKind, nn Number) {
+ switch kind {
+ case Int64NumberKind:
+ n.AddInt64Atomic(nn.AsInt64())
+ case Float64NumberKind:
+ n.AddFloat64Atomic(nn.AsFloat64())
+ }
+}
+
+// AddRawAtomic assumes that this number and the passed raw value are
+// of the passed kind and adds the passed raw value to this number
+// atomically.
+func (n *Number) AddRawAtomic(kind NumberKind, r uint64) {
+ n.AddNumberAtomic(kind, NewNumberFromRaw(r))
+}
+
+// AddInt64Atomic assumes that the number contains an int64 and adds
+// the passed int64 to it atomically.
+func (n *Number) AddInt64Atomic(i int64) {
+ atomic.AddInt64(n.AsInt64Ptr(), i)
+}
+
+// AddFloat64Atomic assumes that the number contains a float64 and
+// adds the passed float64 to it atomically.
+func (n *Number) AddFloat64Atomic(f float64) {
+ for {
+ o := n.AsFloat64Atomic()
+ if n.CompareAndSwapFloat64(o, o+f) {
+ break
+ }
+ }
+}
+
+// - compare and swap (atomic only)
+
+// CompareAndSwapNumber does the atomic CAS operation on this
+// number. This number and passed old and new numbers should be of the
+// same kind.
+func (n *Number) CompareAndSwapNumber(on, nn Number) bool {
+ return atomic.CompareAndSwapUint64(n.AsRawPtr(), on.AsRaw(), nn.AsRaw())
+}
+
+// CompareAndSwapRaw does the atomic CAS operation on this
+// number. This number and passed old and new raw values should be of
+// the same kind.
+func (n *Number) CompareAndSwapRaw(or, nr uint64) bool {
+ return atomic.CompareAndSwapUint64(n.AsRawPtr(), or, nr)
+}
+
+// CompareAndSwapInt64 assumes that this number contains an int64 and
+// does the atomic CAS operation on it.
+func (n *Number) CompareAndSwapInt64(oi, ni int64) bool {
+ return atomic.CompareAndSwapInt64(n.AsInt64Ptr(), oi, ni)
+}
+
+// CompareAndSwapFloat64 assumes that this number contains a float64 and
+// does the atomic CAS operation on it.
+func (n *Number) CompareAndSwapFloat64(of, nf float64) bool {
+ return atomic.CompareAndSwapUint64(n.AsRawPtr(), internal.Float64ToRaw(of), internal.Float64ToRaw(nf))
+}
+
+// - compare
+
+// CompareNumber compares two Numbers given their kind. Both numbers
+// should have the same kind. This returns:
+// 0 if the numbers are equal
+// -1 if the subject `n` is less than the argument `nn`
+// +1 if the subject `n` is greater than the argument `nn`
+func (n *Number) CompareNumber(kind NumberKind, nn Number) int {
+ switch kind {
+ case Int64NumberKind:
+ return n.CompareInt64(nn.AsInt64())
+ case Float64NumberKind:
+ return n.CompareFloat64(nn.AsFloat64())
+ default:
+ // you get what you deserve
+ return 0
+ }
+}
+
+// CompareRaw compares two numbers, where one is input as a raw
+// uint64, interpreting both values as a `kind` of number.
+func (n *Number) CompareRaw(kind NumberKind, r uint64) int {
+ return n.CompareNumber(kind, NewNumberFromRaw(r))
+}
+
+// CompareInt64 assumes that the Number contains an int64 and performs
+// a comparison between the value and the other value. It returns the
+// typical result of the compare function: -1 if the value is less
+// than the other, 0 if both are equal, 1 if the value is greater than
+// the other.
+func (n *Number) CompareInt64(i int64) int {
+ this := n.AsInt64()
+ if this < i {
+ return -1
+ } else if this > i {
+ return 1
+ }
+ return 0
+}
+
+// CompareFloat64 assumes that the Number contains a float64 and
+// performs a comparison between the value and the other value. It
+// returns the typical result of the compare function: -1 if the value
+// is less than the other, 0 if both are equal, 1 if the value is
+// greater than the other.
+//
+// Do not compare NaN values.
+func (n *Number) CompareFloat64(f float64) int {
+ this := n.AsFloat64()
+ if this < f {
+ return -1
+ } else if this > f {
+ return 1
+ }
+ return 0
+}
+
+// - relations to zero
+
+// IsPositive returns true if the actual value is greater than zero.
+func (n *Number) IsPositive(kind NumberKind) bool {
+ return n.compareWithZero(kind) > 0
+}
+
+// IsNegative returns true if the actual value is less than zero.
+func (n *Number) IsNegative(kind NumberKind) bool {
+ return n.compareWithZero(kind) < 0
+}
+
+// IsZero returns true if the actual value is equal to zero.
+func (n *Number) IsZero(kind NumberKind) bool {
+ return n.compareWithZero(kind) == 0
+}
+
+// - misc
+
+// Emit returns a string representation of the raw value of the
+// Number. A %d is used for integral values, %f for floating point
+// values.
+func (n *Number) Emit(kind NumberKind) string {
+ switch kind {
+ case Int64NumberKind:
+ return fmt.Sprintf("%d", n.AsInt64())
+ case Float64NumberKind:
+ return fmt.Sprintf("%f", n.AsFloat64())
+ default:
+ return ""
+ }
+}
+
+// AsInterface returns the number as an interface{}, typically used
+// for NumberKind-correct JSON conversion.
+func (n *Number) AsInterface(kind NumberKind) interface{} {
+ switch kind {
+ case Int64NumberKind:
+ return n.AsInt64()
+ case Float64NumberKind:
+ return n.AsFloat64()
+ default:
+ return math.NaN()
+ }
+}
+
+// - private stuff
+
+func (n *Number) compareWithZero(kind NumberKind) int {
+ switch kind {
+ case Int64NumberKind:
+ return n.CompareInt64(0)
+ case Float64NumberKind:
+ return n.CompareFloat64(0.)
+ default:
+ // you get what you deserve
+ return 0
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/numberkind_string.go b/vendor/go.opentelemetry.io/otel/api/metric/numberkind_string.go
new file mode 100644
index 0000000..e99a874
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/numberkind_string.go
@@ -0,0 +1,24 @@
+// Code generated by "stringer -type=NumberKind"; DO NOT EDIT.
+
+package metric
+
+import "strconv"
+
+func _() {
+ // An "invalid array index" compiler error signifies that the constant values have changed.
+ // Re-run the stringer command to generate them again.
+ var x [1]struct{}
+ _ = x[Int64NumberKind-0]
+ _ = x[Float64NumberKind-1]
+}
+
+const _NumberKind_name = "Int64NumberKindFloat64NumberKind"
+
+var _NumberKind_index = [...]uint8{0, 15, 32}
+
+func (i NumberKind) String() string {
+ if i < 0 || i >= NumberKind(len(_NumberKind_index)-1) {
+ return "NumberKind(" + strconv.FormatInt(int64(i), 10) + ")"
+ }
+ return _NumberKind_name[_NumberKind_index[i]:_NumberKind_index[i+1]]
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/observer.go b/vendor/go.opentelemetry.io/otel/api/metric/observer.go
new file mode 100644
index 0000000..c347da7
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/observer.go
@@ -0,0 +1,124 @@
+// 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 metric
+
+// BatchObserver represents an Observer callback that can report
+// observations for multiple instruments.
+type BatchObserver struct {
+ meter Meter
+ runner AsyncBatchRunner
+}
+
+// Int64ValueObserver is a metric that captures a set of int64 values at a
+// point in time.
+type Int64ValueObserver struct {
+ asyncInstrument
+}
+
+// Float64ValueObserver is a metric that captures a set of float64 values
+// at a point in time.
+type Float64ValueObserver struct {
+ asyncInstrument
+}
+
+// Int64SumObserver is a metric that captures a precomputed sum of
+// int64 values at a point in time.
+type Int64SumObserver struct {
+ asyncInstrument
+}
+
+// Float64SumObserver is a metric that captures a precomputed sum of
+// float64 values at a point in time.
+type Float64SumObserver struct {
+ asyncInstrument
+}
+
+// Int64UpDownSumObserver is a metric that captures a precomputed sum of
+// int64 values at a point in time.
+type Int64UpDownSumObserver struct {
+ asyncInstrument
+}
+
+// Float64UpDownSumObserver is a metric that captures a precomputed sum of
+// float64 values at a point in time.
+type Float64UpDownSumObserver struct {
+ asyncInstrument
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (i Int64ValueObserver) Observation(v int64) Observation {
+ return Observation{
+ number: NewInt64Number(v),
+ instrument: i.instrument,
+ }
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (f Float64ValueObserver) Observation(v float64) Observation {
+ return Observation{
+ number: NewFloat64Number(v),
+ instrument: f.instrument,
+ }
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (i Int64SumObserver) Observation(v int64) Observation {
+ return Observation{
+ number: NewInt64Number(v),
+ instrument: i.instrument,
+ }
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (f Float64SumObserver) Observation(v float64) Observation {
+ return Observation{
+ number: NewFloat64Number(v),
+ instrument: f.instrument,
+ }
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (i Int64UpDownSumObserver) Observation(v int64) Observation {
+ return Observation{
+ number: NewInt64Number(v),
+ instrument: i.instrument,
+ }
+}
+
+// Observation returns an Observation, a BatchObserverFunc
+// argument, for an asynchronous integer instrument.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (f Float64UpDownSumObserver) Observation(v float64) Observation {
+ return Observation{
+ number: NewFloat64Number(v),
+ instrument: f.instrument,
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/registry/registry.go b/vendor/go.opentelemetry.io/otel/api/metric/registry/registry.go
new file mode 100644
index 0000000..ed9eccc
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/registry/registry.go
@@ -0,0 +1,170 @@
+// 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 registry // import "go.opentelemetry.io/otel/api/metric/registry"
+
+import (
+ "context"
+ "fmt"
+ "sync"
+
+ "go.opentelemetry.io/otel/api/metric"
+ "go.opentelemetry.io/otel/label"
+)
+
+// MeterProvider is a standard MeterProvider for wrapping `MeterImpl`
+type MeterProvider struct {
+ impl metric.MeterImpl
+}
+
+var _ metric.MeterProvider = (*MeterProvider)(nil)
+
+// uniqueInstrumentMeterImpl implements the metric.MeterImpl interface, adding
+// uniqueness checking for instrument descriptors. Use NewUniqueInstrumentMeter
+// to wrap an implementation with uniqueness checking.
+type uniqueInstrumentMeterImpl struct {
+ lock sync.Mutex
+ impl metric.MeterImpl
+ state map[key]metric.InstrumentImpl
+}
+
+var _ metric.MeterImpl = (*uniqueInstrumentMeterImpl)(nil)
+
+type key struct {
+ instrumentName string
+ instrumentationName string
+ InstrumentationVersion string
+}
+
+// NewMeterProvider returns a new provider that implements instrument
+// name-uniqueness checking.
+func NewMeterProvider(impl metric.MeterImpl) *MeterProvider {
+ return &MeterProvider{
+ impl: NewUniqueInstrumentMeterImpl(impl),
+ }
+}
+
+// Meter implements MeterProvider.
+func (p *MeterProvider) Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
+ return metric.WrapMeterImpl(p.impl, instrumentationName, opts...)
+}
+
+// ErrMetricKindMismatch is the standard error for mismatched metric
+// instrument definitions.
+var ErrMetricKindMismatch = fmt.Errorf(
+ "A metric was already registered by this name with another kind or number type")
+
+// NewUniqueInstrumentMeterImpl returns a wrapped metric.MeterImpl with
+// the addition of uniqueness checking.
+func NewUniqueInstrumentMeterImpl(impl metric.MeterImpl) metric.MeterImpl {
+ return &uniqueInstrumentMeterImpl{
+ impl: impl,
+ state: map[key]metric.InstrumentImpl{},
+ }
+}
+
+// RecordBatch implements metric.MeterImpl.
+func (u *uniqueInstrumentMeterImpl) RecordBatch(ctx context.Context, labels []label.KeyValue, ms ...metric.Measurement) {
+ u.impl.RecordBatch(ctx, labels, ms...)
+}
+
+func keyOf(descriptor metric.Descriptor) key {
+ return key{
+ descriptor.Name(),
+ descriptor.InstrumentationName(),
+ descriptor.InstrumentationVersion(),
+ }
+}
+
+// NewMetricKindMismatchError formats an error that describes a
+// mismatched metric instrument definition.
+func NewMetricKindMismatchError(desc metric.Descriptor) error {
+ return fmt.Errorf("Metric was %s (%s %s)registered as a %s %s: %w",
+ desc.Name(),
+ desc.InstrumentationName(),
+ desc.InstrumentationVersion(),
+ desc.NumberKind(),
+ desc.MetricKind(),
+ ErrMetricKindMismatch)
+}
+
+// Compatible determines whether two metric.Descriptors are considered
+// the same for the purpose of uniqueness checking.
+func Compatible(candidate, existing metric.Descriptor) bool {
+ return candidate.MetricKind() == existing.MetricKind() &&
+ candidate.NumberKind() == existing.NumberKind()
+}
+
+// checkUniqueness returns an ErrMetricKindMismatch error if there is
+// a conflict between a descriptor that was already registered and the
+// `descriptor` argument. If there is an existing compatible
+// registration, this returns the already-registered instrument. If
+// there is no conflict and no prior registration, returns (nil, nil).
+func (u *uniqueInstrumentMeterImpl) checkUniqueness(descriptor metric.Descriptor) (metric.InstrumentImpl, error) {
+ impl, ok := u.state[keyOf(descriptor)]
+ if !ok {
+ return nil, nil
+ }
+
+ if !Compatible(descriptor, impl.Descriptor()) {
+ return nil, NewMetricKindMismatchError(impl.Descriptor())
+ }
+
+ return impl, nil
+}
+
+// NewSyncInstrument implements metric.MeterImpl.
+func (u *uniqueInstrumentMeterImpl) NewSyncInstrument(descriptor metric.Descriptor) (metric.SyncImpl, error) {
+ u.lock.Lock()
+ defer u.lock.Unlock()
+
+ impl, err := u.checkUniqueness(descriptor)
+
+ if err != nil {
+ return nil, err
+ } else if impl != nil {
+ return impl.(metric.SyncImpl), nil
+ }
+
+ syncInst, err := u.impl.NewSyncInstrument(descriptor)
+ if err != nil {
+ return nil, err
+ }
+ u.state[keyOf(descriptor)] = syncInst
+ return syncInst, nil
+}
+
+// NewAsyncInstrument implements metric.MeterImpl.
+func (u *uniqueInstrumentMeterImpl) NewAsyncInstrument(
+ descriptor metric.Descriptor,
+ runner metric.AsyncRunner,
+) (metric.AsyncImpl, error) {
+ u.lock.Lock()
+ defer u.lock.Unlock()
+
+ impl, err := u.checkUniqueness(descriptor)
+
+ if err != nil {
+ return nil, err
+ } else if impl != nil {
+ return impl.(metric.AsyncImpl), nil
+ }
+
+ asyncInst, err := u.impl.NewAsyncInstrument(descriptor, runner)
+ if err != nil {
+ return nil, err
+ }
+ u.state[keyOf(descriptor)] = asyncInst
+ return asyncInst, nil
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/sdkapi.go b/vendor/go.opentelemetry.io/otel/api/metric/sdkapi.go
new file mode 100644
index 0000000..122c9ba
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/sdkapi.go
@@ -0,0 +1,94 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// MeterImpl is the interface an SDK must implement to supply a Meter
+// implementation.
+type MeterImpl interface {
+ // RecordBatch atomically records a batch of measurements.
+ RecordBatch(ctx context.Context, labels []label.KeyValue, measurement ...Measurement)
+
+ // NewSyncInstrument returns a newly constructed
+ // synchronous instrument implementation or an error, should
+ // one occur.
+ NewSyncInstrument(descriptor Descriptor) (SyncImpl, error)
+
+ // NewAsyncInstrument returns a newly constructed
+ // asynchronous instrument implementation or an error, should
+ // one occur.
+ NewAsyncInstrument(
+ descriptor Descriptor,
+ runner AsyncRunner,
+ ) (AsyncImpl, error)
+}
+
+// InstrumentImpl is a common interface for synchronous and
+// asynchronous instruments.
+type InstrumentImpl interface {
+ // Implementation returns the underlying implementation of the
+ // instrument, which allows the implementation to gain access
+ // to its own representation especially from a `Measurement`.
+ Implementation() interface{}
+
+ // Descriptor returns a copy of the instrument's Descriptor.
+ Descriptor() Descriptor
+}
+
+// SyncImpl is the implementation-level interface to a generic
+// synchronous instrument (e.g., ValueRecorder and Counter instruments).
+type SyncImpl interface {
+ InstrumentImpl
+
+ // Bind creates an implementation-level bound instrument,
+ // binding a label set with this instrument implementation.
+ Bind(labels []label.KeyValue) BoundSyncImpl
+
+ // RecordOne captures a single synchronous metric event.
+ RecordOne(ctx context.Context, number Number, labels []label.KeyValue)
+}
+
+// BoundSyncImpl is the implementation-level interface to a
+// generic bound synchronous instrument
+type BoundSyncImpl interface {
+
+ // RecordOne captures a single synchronous metric event.
+ RecordOne(ctx context.Context, number Number)
+
+ // Unbind frees the resources associated with this bound instrument. It
+ // does not affect the metric this bound instrument was created through.
+ Unbind()
+}
+
+// AsyncImpl is an implementation-level interface to an
+// asynchronous instrument (e.g., Observer instruments).
+type AsyncImpl interface {
+ InstrumentImpl
+}
+
+// WrapMeterImpl constructs a `Meter` implementation from a
+// `MeterImpl` implementation.
+func WrapMeterImpl(impl MeterImpl, instrumentationName string, opts ...MeterOption) Meter {
+ return Meter{
+ impl: impl,
+ name: instrumentationName,
+ version: NewMeterConfig(opts...).InstrumentationVersion,
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/sync.go b/vendor/go.opentelemetry.io/otel/api/metric/sync.go
new file mode 100644
index 0000000..a08a65b
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/sync.go
@@ -0,0 +1,192 @@
+// 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 metric
+
+import (
+ "context"
+ "errors"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// ErrSDKReturnedNilImpl is returned when a new `MeterImpl` returns nil.
+var ErrSDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
+
+// Measurement is used for reporting a synchronous batch of metric
+// values. Instances of this type should be created by synchronous
+// instruments (e.g., Int64Counter.Measurement()).
+type Measurement struct {
+ // number needs to be aligned for 64-bit atomic operations.
+ number Number
+ instrument SyncImpl
+}
+
+// syncInstrument contains a SyncImpl.
+type syncInstrument struct {
+ instrument SyncImpl
+}
+
+// syncBoundInstrument contains a BoundSyncImpl.
+type syncBoundInstrument struct {
+ boundInstrument BoundSyncImpl
+}
+
+// asyncInstrument contains a AsyncImpl.
+type asyncInstrument struct {
+ instrument AsyncImpl
+}
+
+// SyncImpl returns the instrument that created this measurement.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (m Measurement) SyncImpl() SyncImpl {
+ return m.instrument
+}
+
+// Number returns a number recorded in this measurement.
+func (m Measurement) Number() Number {
+ return m.number
+}
+
+// AsyncImpl returns the instrument that created this observation.
+// This returns an implementation-level object for use by the SDK,
+// users should not refer to this.
+func (m Observation) AsyncImpl() AsyncImpl {
+ return m.instrument
+}
+
+// Number returns a number recorded in this observation.
+func (m Observation) Number() Number {
+ return m.number
+}
+
+// AsyncImpl implements AsyncImpl.
+func (a asyncInstrument) AsyncImpl() AsyncImpl {
+ return a.instrument
+}
+
+// SyncImpl returns the implementation object for synchronous instruments.
+func (s syncInstrument) SyncImpl() SyncImpl {
+ return s.instrument
+}
+
+func (s syncInstrument) bind(labels []label.KeyValue) syncBoundInstrument {
+ return newSyncBoundInstrument(s.instrument.Bind(labels))
+}
+
+func (s syncInstrument) float64Measurement(value float64) Measurement {
+ return newMeasurement(s.instrument, NewFloat64Number(value))
+}
+
+func (s syncInstrument) int64Measurement(value int64) Measurement {
+ return newMeasurement(s.instrument, NewInt64Number(value))
+}
+
+func (s syncInstrument) directRecord(ctx context.Context, number Number, labels []label.KeyValue) {
+ s.instrument.RecordOne(ctx, number, labels)
+}
+
+func (h syncBoundInstrument) directRecord(ctx context.Context, number Number) {
+ h.boundInstrument.RecordOne(ctx, number)
+}
+
+// Unbind calls SyncImpl.Unbind.
+func (h syncBoundInstrument) Unbind() {
+ h.boundInstrument.Unbind()
+}
+
+// checkNewAsync receives an AsyncImpl and potential
+// error, and returns the same types, checking for and ensuring that
+// the returned interface is not nil.
+func checkNewAsync(instrument AsyncImpl, err error) (asyncInstrument, error) {
+ if instrument == nil {
+ if err == nil {
+ err = ErrSDKReturnedNilImpl
+ }
+ instrument = NoopAsync{}
+ }
+ return asyncInstrument{
+ instrument: instrument,
+ }, err
+}
+
+// checkNewSync receives an SyncImpl and potential
+// error, and returns the same types, checking for and ensuring that
+// the returned interface is not nil.
+func checkNewSync(instrument SyncImpl, err error) (syncInstrument, error) {
+ if instrument == nil {
+ if err == nil {
+ err = ErrSDKReturnedNilImpl
+ }
+ // Note: an alternate behavior would be to synthesize a new name
+ // or group all duplicately-named instruments of a certain type
+ // together and use a tag for the original name, e.g.,
+ // name = 'invalid.counter.int64'
+ // label = 'original-name=duplicate-counter-name'
+ instrument = NoopSync{}
+ }
+ return syncInstrument{
+ instrument: instrument,
+ }, err
+}
+
+func newSyncBoundInstrument(boundInstrument BoundSyncImpl) syncBoundInstrument {
+ return syncBoundInstrument{
+ boundInstrument: boundInstrument,
+ }
+}
+
+func newMeasurement(instrument SyncImpl, number Number) Measurement {
+ return Measurement{
+ instrument: instrument,
+ number: number,
+ }
+}
+
+// wrapInt64CounterInstrument converts a SyncImpl into Int64Counter.
+func wrapInt64CounterInstrument(syncInst SyncImpl, err error) (Int64Counter, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Int64Counter{syncInstrument: common}, err
+}
+
+// wrapFloat64CounterInstrument converts a SyncImpl into Float64Counter.
+func wrapFloat64CounterInstrument(syncInst SyncImpl, err error) (Float64Counter, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Float64Counter{syncInstrument: common}, err
+}
+
+// wrapInt64UpDownCounterInstrument converts a SyncImpl into Int64UpDownCounter.
+func wrapInt64UpDownCounterInstrument(syncInst SyncImpl, err error) (Int64UpDownCounter, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Int64UpDownCounter{syncInstrument: common}, err
+}
+
+// wrapFloat64UpDownCounterInstrument converts a SyncImpl into Float64UpDownCounter.
+func wrapFloat64UpDownCounterInstrument(syncInst SyncImpl, err error) (Float64UpDownCounter, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Float64UpDownCounter{syncInstrument: common}, err
+}
+
+// wrapInt64ValueRecorderInstrument converts a SyncImpl into Int64ValueRecorder.
+func wrapInt64ValueRecorderInstrument(syncInst SyncImpl, err error) (Int64ValueRecorder, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Int64ValueRecorder{syncInstrument: common}, err
+}
+
+// wrapFloat64ValueRecorderInstrument converts a SyncImpl into Float64ValueRecorder.
+func wrapFloat64ValueRecorderInstrument(syncInst SyncImpl, err error) (Float64ValueRecorder, error) {
+ common, err := checkNewSync(syncInst, err)
+ return Float64ValueRecorder{syncInstrument: common}, err
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/updowncounter.go b/vendor/go.opentelemetry.io/otel/api/metric/updowncounter.go
new file mode 100644
index 0000000..1018246
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/updowncounter.go
@@ -0,0 +1,96 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// Float64UpDownCounter is a metric instrument that sums floating
+// point values.
+type Float64UpDownCounter struct {
+ syncInstrument
+}
+
+// Int64UpDownCounter is a metric instrument that sums integer values.
+type Int64UpDownCounter struct {
+ syncInstrument
+}
+
+// BoundFloat64UpDownCounter is a bound instrument for Float64UpDownCounter.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundFloat64UpDownCounter struct {
+ syncBoundInstrument
+}
+
+// BoundInt64UpDownCounter is a boundInstrument for Int64UpDownCounter.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundInt64UpDownCounter struct {
+ syncBoundInstrument
+}
+
+// Bind creates a bound instrument for this counter. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Float64UpDownCounter) Bind(labels ...label.KeyValue) (h BoundFloat64UpDownCounter) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Bind creates a bound instrument for this counter. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Int64UpDownCounter) Bind(labels ...label.KeyValue) (h BoundInt64UpDownCounter) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Float64UpDownCounter) Measurement(value float64) Measurement {
+ return c.float64Measurement(value)
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Int64UpDownCounter) Measurement(value int64) Measurement {
+ return c.int64Measurement(value)
+}
+
+// Add adds the value to the counter's sum. The labels should contain
+// the keys and values to be associated with this value.
+func (c Float64UpDownCounter) Add(ctx context.Context, value float64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewFloat64Number(value), labels)
+}
+
+// Add adds the value to the counter's sum. The labels should contain
+// the keys and values to be associated with this value.
+func (c Int64UpDownCounter) Add(ctx context.Context, value int64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewInt64Number(value), labels)
+}
+
+// Add adds the value to the counter's sum using the labels
+// previously bound to this counter via Bind()
+func (b BoundFloat64UpDownCounter) Add(ctx context.Context, value float64) {
+ b.directRecord(ctx, NewFloat64Number(value))
+}
+
+// Add adds the value to the counter's sum using the labels
+// previously bound to this counter via Bind()
+func (b BoundInt64UpDownCounter) Add(ctx context.Context, value int64) {
+ b.directRecord(ctx, NewInt64Number(value))
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/metric/valuerecorder.go b/vendor/go.opentelemetry.io/otel/api/metric/valuerecorder.go
new file mode 100644
index 0000000..fa7e2d4
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/metric/valuerecorder.go
@@ -0,0 +1,97 @@
+// 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 metric
+
+import (
+ "context"
+
+ "go.opentelemetry.io/otel/label"
+)
+
+// Float64ValueRecorder is a metric that records float64 values.
+type Float64ValueRecorder struct {
+ syncInstrument
+}
+
+// Int64ValueRecorder is a metric that records int64 values.
+type Int64ValueRecorder struct {
+ syncInstrument
+}
+
+// BoundFloat64ValueRecorder is a bound instrument for Float64ValueRecorder.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundFloat64ValueRecorder struct {
+ syncBoundInstrument
+}
+
+// BoundInt64ValueRecorder is a bound instrument for Int64ValueRecorder.
+//
+// It inherits the Unbind function from syncBoundInstrument.
+type BoundInt64ValueRecorder struct {
+ syncBoundInstrument
+}
+
+// Bind creates a bound instrument for this ValueRecorder. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Float64ValueRecorder) Bind(labels ...label.KeyValue) (h BoundFloat64ValueRecorder) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Bind creates a bound instrument for this ValueRecorder. The labels are
+// associated with values recorded via subsequent calls to Record.
+func (c Int64ValueRecorder) Bind(labels ...label.KeyValue) (h BoundInt64ValueRecorder) {
+ h.syncBoundInstrument = c.bind(labels)
+ return
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Float64ValueRecorder) Measurement(value float64) Measurement {
+ return c.float64Measurement(value)
+}
+
+// Measurement creates a Measurement object to use with batch
+// recording.
+func (c Int64ValueRecorder) Measurement(value int64) Measurement {
+ return c.int64Measurement(value)
+}
+
+// Record adds a new value to the list of ValueRecorder's records. The
+// labels should contain the keys and values to be associated with
+// this value.
+func (c Float64ValueRecorder) Record(ctx context.Context, value float64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewFloat64Number(value), labels)
+}
+
+// Record adds a new value to the ValueRecorder's distribution. The
+// labels should contain the keys and values to be associated with
+// this value.
+func (c Int64ValueRecorder) Record(ctx context.Context, value int64, labels ...label.KeyValue) {
+ c.directRecord(ctx, NewInt64Number(value), labels)
+}
+
+// Record adds a new value to the ValueRecorder's distribution using the labels
+// previously bound to the ValueRecorder via Bind().
+func (b BoundFloat64ValueRecorder) Record(ctx context.Context, value float64) {
+ b.directRecord(ctx, NewFloat64Number(value))
+}
+
+// Record adds a new value to the ValueRecorder's distribution using the labels
+// previously bound to the ValueRecorder via Bind().
+func (b BoundInt64ValueRecorder) Record(ctx context.Context, value int64) {
+ b.directRecord(ctx, NewInt64Number(value))
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/api.go b/vendor/go.opentelemetry.io/otel/api/trace/api.go
new file mode 100644
index 0000000..3f15f48
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/api.go
@@ -0,0 +1,314 @@
+// 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 trace
+
+import (
+ "context"
+ "time"
+
+ "go.opentelemetry.io/otel/codes"
+ "go.opentelemetry.io/otel/label"
+)
+
+// TracerProvider provides access to instrumentation Tracers.
+type TracerProvider interface {
+ // Tracer creates an implementation of the Tracer interface.
+ // 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.
+ Tracer(instrumentationName string, opts ...TracerOption) Tracer
+}
+
+// TracerConfig is a group of options for a Tracer.
+//
+// Most users will use the tracer options instead.
+type TracerConfig struct {
+ // InstrumentationVersion is the version of the instrumentation library.
+ InstrumentationVersion string
+}
+
+// NewTracerConfig applies all the options to a returned TracerConfig.
+// The default value for all the fields of the returned TracerConfig are the
+// default zero value of the type. Also, this does not perform any validation
+// on the returned TracerConfig (e.g. no uniqueness checking or bounding of
+// data), instead it is left to the implementations of the SDK to perform this
+// action.
+func NewTracerConfig(opts ...TracerOption) *TracerConfig {
+ config := new(TracerConfig)
+ for _, option := range opts {
+ option.Apply(config)
+ }
+ return config
+}
+
+// TracerOption applies an options to a TracerConfig.
+type TracerOption interface {
+ Apply(*TracerConfig)
+}
+
+type instVersionTracerOption string
+
+func (o instVersionTracerOption) Apply(c *TracerConfig) { c.InstrumentationVersion = string(o) }
+
+// WithInstrumentationVersion sets the instrumentation version for a Tracer.
+func WithInstrumentationVersion(version string) TracerOption {
+ return instVersionTracerOption(version)
+}
+
+type Tracer interface {
+ // Start a span.
+ Start(ctx context.Context, spanName string, opts ...SpanOption) (context.Context, Span)
+}
+
+// ErrorConfig provides options to set properties of an error
+// event at the time it is recorded.
+//
+// Most users will use the error options instead.
+type ErrorConfig struct {
+ Timestamp time.Time
+ StatusCode codes.Code
+}
+
+// ErrorOption applies changes to ErrorConfig that sets options when an error event is recorded.
+type ErrorOption func(*ErrorConfig)
+
+// WithErrorTime sets the time at which the error event should be recorded.
+func WithErrorTime(t time.Time) ErrorOption {
+ return func(c *ErrorConfig) {
+ c.Timestamp = t
+ }
+}
+
+// WithErrorStatus indicates the span status that should be set when recording an error event.
+func WithErrorStatus(s codes.Code) ErrorOption {
+ return func(c *ErrorConfig) {
+ c.StatusCode = s
+ }
+}
+
+type Span interface {
+ // Tracer returns tracer used to create this span. Tracer cannot be nil.
+ Tracer() Tracer
+
+ // End completes the span. No updates are allowed to span after it
+ // ends. The only exception is setting status of the span.
+ End(options ...SpanOption)
+
+ // AddEvent adds an event to the span.
+ AddEvent(ctx context.Context, name string, attrs ...label.KeyValue)
+ // AddEventWithTimestamp adds an event with a custom timestamp
+ // to the span.
+ AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue)
+
+ // IsRecording returns true if the span is active and recording events is enabled.
+ IsRecording() bool
+
+ // RecordError records an error as a span event.
+ RecordError(ctx context.Context, err error, opts ...ErrorOption)
+
+ // SpanContext returns span context of the span. Returned SpanContext is usable
+ // even after the span ends.
+ SpanContext() SpanContext
+
+ // SetStatus sets the status of the span in the form of a code
+ // and a message. SetStatus overrides the value of previous
+ // calls to SetStatus on the Span.
+ //
+ // The default span status is OK, so it is not necessary to
+ // explicitly set an OK status on successful Spans unless it
+ // is to add an OK message or to override a previous status on the Span.
+ SetStatus(code codes.Code, msg string)
+
+ // SetName sets the name of the span.
+ SetName(name string)
+
+ // Set span attributes
+ SetAttributes(kv ...label.KeyValue)
+}
+
+// SpanConfig is a group of options for a Span.
+//
+// Most users will use span options instead.
+type SpanConfig struct {
+ // Attributes describe the associated qualities of a Span.
+ Attributes []label.KeyValue
+ // Timestamp is a time in a Span life-cycle.
+ Timestamp time.Time
+ // Links are the associations a Span has with other Spans.
+ Links []Link
+ // Record is the recording state of a Span.
+ Record bool
+ // NewRoot identifies a Span as the root Span for a new trace. This is
+ // commonly used when an existing trace crosses trust boundaries and the
+ // remote parent span context should be ignored for security.
+ NewRoot bool
+ // SpanKind is the role a Span has in a trace.
+ SpanKind SpanKind
+}
+
+// NewSpanConfig applies all the options to a returned SpanConfig.
+// The default value for all the fields of the returned SpanConfig are the
+// default zero value of the type. Also, this does not perform any validation
+// on the returned SpanConfig (e.g. no uniqueness checking or bounding of
+// data). Instead, it is left to the implementations of the SDK to perform this
+// action.
+func NewSpanConfig(opts ...SpanOption) *SpanConfig {
+ c := new(SpanConfig)
+ for _, option := range opts {
+ option.Apply(c)
+ }
+ return c
+}
+
+// SpanOption applies an option to a SpanConfig.
+type SpanOption interface {
+ Apply(*SpanConfig)
+}
+
+type attributeSpanOption []label.KeyValue
+
+func (o attributeSpanOption) Apply(c *SpanConfig) {
+ c.Attributes = append(c.Attributes, []label.KeyValue(o)...)
+}
+
+// WithAttributes adds the attributes to a span. These attributes are meant to
+// provide additional information about the work the Span represents. The
+// attributes are added to the existing Span attributes, i.e. this does not
+// overwrite.
+func WithAttributes(attributes ...label.KeyValue) SpanOption {
+ return attributeSpanOption(attributes)
+}
+
+type timestampSpanOption time.Time
+
+func (o timestampSpanOption) Apply(c *SpanConfig) { c.Timestamp = time.Time(o) }
+
+// WithTimestamp sets the time of a Span life-cycle moment (e.g. started or
+// stopped).
+func WithTimestamp(t time.Time) SpanOption {
+ return timestampSpanOption(t)
+}
+
+type linksSpanOption []Link
+
+func (o linksSpanOption) Apply(c *SpanConfig) { c.Links = append(c.Links, []Link(o)...) }
+
+// WithLinks adds links to a Span. The links are added to the existing Span
+// links, i.e. this does not overwrite.
+func WithLinks(links ...Link) SpanOption {
+ return linksSpanOption(links)
+}
+
+type recordSpanOption bool
+
+func (o recordSpanOption) Apply(c *SpanConfig) { c.Record = bool(o) }
+
+// WithRecord specifies that the span should be recorded. It is important to
+// note that implementations may override this option, i.e. if the span is a
+// child of an un-sampled trace.
+func WithRecord() SpanOption {
+ return recordSpanOption(true)
+}
+
+type newRootSpanOption bool
+
+func (o newRootSpanOption) Apply(c *SpanConfig) { c.NewRoot = bool(o) }
+
+// WithNewRoot specifies that the Span should be treated as a root Span. Any
+// existing parent span context will be ignored when defining the Span's trace
+// identifiers.
+func WithNewRoot() SpanOption {
+ return newRootSpanOption(true)
+}
+
+type spanKindSpanOption SpanKind
+
+func (o spanKindSpanOption) Apply(c *SpanConfig) { c.SpanKind = SpanKind(o) }
+
+// WithSpanKind sets the SpanKind of a Span.
+func WithSpanKind(kind SpanKind) SpanOption {
+ return spanKindSpanOption(kind)
+}
+
+// Link is used to establish relationship between two spans within the same Trace or
+// across different Traces. Few examples of Link usage.
+// 1. Batch Processing: A batch of elements may contain elements associated with one
+// or more traces/spans. Since there can only be one parent SpanContext, Link is
+// used to keep reference to SpanContext of all elements in the batch.
+// 2. Public Endpoint: A SpanContext in incoming client request on a public endpoint
+// is untrusted from service provider perspective. In such case it is advisable to
+// start a new trace with appropriate sampling decision.
+// However, it is desirable to associate incoming SpanContext to new trace initiated
+// on service provider side so two traces (from Client and from Service Provider) can
+// be correlated.
+type Link struct {
+ SpanContext
+ Attributes []label.KeyValue
+}
+
+// SpanKind represents the role of a Span inside a Trace. Often, this defines how a Span
+// will be processed and visualized by various backends.
+type SpanKind int
+
+const (
+ // As a convenience, these match the proto definition, see
+ // opentelemetry/proto/trace/v1/trace.proto
+ //
+ // The unspecified value is not a valid `SpanKind`. Use
+ // `ValidateSpanKind()` to coerce a span kind to a valid
+ // value.
+ SpanKindUnspecified SpanKind = 0
+ SpanKindInternal SpanKind = 1
+ SpanKindServer SpanKind = 2
+ SpanKindClient SpanKind = 3
+ SpanKindProducer SpanKind = 4
+ SpanKindConsumer SpanKind = 5
+)
+
+// ValidateSpanKind returns a valid span kind value. This will coerce
+// invalid values into the default value, SpanKindInternal.
+func ValidateSpanKind(spanKind SpanKind) SpanKind {
+ switch spanKind {
+ case SpanKindInternal,
+ SpanKindServer,
+ SpanKindClient,
+ SpanKindProducer,
+ SpanKindConsumer:
+ // valid
+ return spanKind
+ default:
+ return SpanKindInternal
+ }
+}
+
+// String returns the specified name of the SpanKind in lower-case.
+func (sk SpanKind) String() string {
+ switch sk {
+ case SpanKindInternal:
+ return "internal"
+ case SpanKindServer:
+ return "server"
+ case SpanKindClient:
+ return "client"
+ case SpanKindProducer:
+ return "producer"
+ case SpanKindConsumer:
+ return "consumer"
+ default:
+ return "unspecified"
+ }
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/context.go b/vendor/go.opentelemetry.io/otel/api/trace/context.go
new file mode 100644
index 0000000..0f330e3
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/context.go
@@ -0,0 +1,55 @@
+// 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 trace
+
+import (
+ "context"
+)
+
+type traceContextKeyType int
+
+const (
+ currentSpanKey traceContextKeyType = iota
+ remoteContextKey
+)
+
+// ContextWithSpan creates a new context with a current span set to
+// the passed span.
+func ContextWithSpan(ctx context.Context, span Span) context.Context {
+ return context.WithValue(ctx, currentSpanKey, span)
+}
+
+// SpanFromContext returns the current span stored in the context.
+func SpanFromContext(ctx context.Context) Span {
+ if span, has := ctx.Value(currentSpanKey).(Span); has {
+ return span
+ }
+ return noopSpan{}
+}
+
+// ContextWithRemoteSpanContext creates a new context with a remote
+// span context set to the passed span context.
+func ContextWithRemoteSpanContext(ctx context.Context, sc SpanContext) context.Context {
+ return context.WithValue(ctx, remoteContextKey, sc)
+}
+
+// RemoteSpanContextFromContext returns the remote span context stored
+// in the context.
+func RemoteSpanContextFromContext(ctx context.Context) SpanContext {
+ if sc, ok := ctx.Value(remoteContextKey).(SpanContext); ok {
+ return sc
+ }
+ return EmptySpanContext()
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/doc.go b/vendor/go.opentelemetry.io/otel/api/trace/doc.go
new file mode 100644
index 0000000..24f2dfb
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/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 trace provides tracing support.
+package trace // import "go.opentelemetry.io/otel/api/trace"
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/noop_span.go b/vendor/go.opentelemetry.io/otel/api/trace/noop_span.go
new file mode 100644
index 0000000..f014f21
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/noop_span.go
@@ -0,0 +1,75 @@
+// 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 trace
+
+import (
+ "context"
+ "time"
+
+ "go.opentelemetry.io/otel/codes"
+ "go.opentelemetry.io/otel/label"
+)
+
+type noopSpan struct {
+}
+
+var _ Span = noopSpan{}
+
+// SpanContext returns an invalid span context.
+func (noopSpan) SpanContext() SpanContext {
+ return EmptySpanContext()
+}
+
+// IsRecording always returns false for NoopSpan.
+func (noopSpan) IsRecording() bool {
+ return false
+}
+
+// SetStatus does nothing.
+func (noopSpan) SetStatus(status codes.Code, msg string) {
+}
+
+// SetError does nothing.
+func (noopSpan) SetError(v bool) {
+}
+
+// SetAttributes does nothing.
+func (noopSpan) SetAttributes(attributes ...label.KeyValue) {
+}
+
+// End does nothing.
+func (noopSpan) End(options ...SpanOption) {
+}
+
+// RecordError does nothing.
+func (noopSpan) RecordError(ctx context.Context, err error, opts ...ErrorOption) {
+}
+
+// Tracer returns noop implementation of Tracer.
+func (noopSpan) Tracer() Tracer {
+ return noopTracer{}
+}
+
+// AddEvent does nothing.
+func (noopSpan) AddEvent(ctx context.Context, name string, attrs ...label.KeyValue) {
+}
+
+// AddEventWithTimestamp does nothing.
+func (noopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...label.KeyValue) {
+}
+
+// SetName does nothing.
+func (noopSpan) SetName(name string) {
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/noop_trace.go b/vendor/go.opentelemetry.io/otel/api/trace/noop_trace.go
new file mode 100644
index 0000000..954f9e8
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/noop_trace.go
@@ -0,0 +1,29 @@
+// 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 trace
+
+import (
+ "context"
+)
+
+type noopTracer struct{}
+
+var _ Tracer = noopTracer{}
+
+// Start starts a noop span.
+func (noopTracer) Start(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span) {
+ span := noopSpan{}
+ return ContextWithSpan(ctx, span), span
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/noop_trace_provider.go b/vendor/go.opentelemetry.io/otel/api/trace/noop_trace_provider.go
new file mode 100644
index 0000000..414c8e3
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/noop_trace_provider.go
@@ -0,0 +1,30 @@
+// 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 trace
+
+type noopTracerProvider struct{}
+
+var _ TracerProvider = noopTracerProvider{}
+
+// Tracer returns noop implementation of Tracer.
+func (p noopTracerProvider) Tracer(_ string, _ ...TracerOption) Tracer {
+ return noopTracer{}
+}
+
+// NoopTracerProvider returns a noop implementation of TracerProvider. The
+// Tracer and Spans created from the noop provider will also be noop.
+func NoopTracerProvider() TracerProvider {
+ return noopTracerProvider{}
+}
diff --git a/vendor/go.opentelemetry.io/otel/api/trace/span_context.go b/vendor/go.opentelemetry.io/otel/api/trace/span_context.go
new file mode 100644
index 0000000..914ce5f
--- /dev/null
+++ b/vendor/go.opentelemetry.io/otel/api/trace/span_context.go
@@ -0,0 +1,197 @@
+// 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 trace
+
+import (
+ "bytes"
+ "encoding/hex"
+ "encoding/json"
+)
+
+const (
+ // FlagsSampled is a bitmask with the sampled bit set. A SpanContext
+ // with the sampling bit set means the span is sampled.
+ FlagsSampled = byte(0x01)
+ // FlagsDeferred is a bitmask with the deferred bit set. A SpanContext
+ // with the deferred bit set means the sampling decision has been
+ // defered to the receiver.
+ FlagsDeferred = byte(0x02)
+ // FlagsDebug is a bitmask with the debug bit set.
+ FlagsDebug = byte(0x04)
+
+ ErrInvalidHexID errorConst = "trace-id and span-id can only contain [0-9a-f] characters, all lowercase"
+
+ ErrInvalidTraceIDLength errorConst = "hex encoded trace-id must have length equals to 32"
+ ErrNilTraceID errorConst = "trace-id can't be all zero"
+
+ ErrInvalidSpanIDLength errorConst = "hex encoded span-id must have length equals to 16"
+ ErrNilSpanID errorConst = "span-id can't be all zero"
+)
+
+type errorConst string
+
+func (e errorConst) Error() string {
+ return string(e)
+}
+
+// ID is a unique identity of a trace.
+type ID [16]byte
+
+var nilTraceID ID
+var _ json.Marshaler = nilTraceID
+
+// IsValid checks whether the trace ID is valid. A valid trace ID does
+// not consist of zeros only.
+func (t ID) IsValid() bool {
+ return !bytes.Equal(t[:], nilTraceID[:])
+}
+
+// MarshalJSON implements a custom marshal function to encode TraceID
+// as a hex string.
+func (t ID) MarshalJSON() ([]byte, error) {
+ return json.Marshal(t.String())
+}
+
+// String returns the hex string representation form of a TraceID
+func (t ID) String() string {
+ return hex.EncodeToString(t[:])
+}
+
+// SpanID is a unique identify of a span in a trace.
+type SpanID [8]byte
+
+var nilSpanID SpanID
+var _ json.Marshaler = nilSpanID
+
+// IsValid checks whether the span ID is valid. A valid span ID does
+// not consist of zeros only.
+func (s SpanID) IsValid() bool {
+ return !bytes.Equal(s[:], nilSpanID[:])
+}
+
+// MarshalJSON implements a custom marshal function to encode SpanID
+// as a hex string.
+func (s SpanID) MarshalJSON() ([]byte, error) {
+ return json.Marshal(s.String())
+}
+
+// String returns the hex string representation form of a SpanID
+func (s SpanID) String() string {
+ return hex.EncodeToString(s[:])
+}
+
+// IDFromHex returns a TraceID from a hex string if it is compliant
+// with the w3c trace-context specification.
+// See more at https://www.w3.org/TR/trace-context/#trace-id
+func IDFromHex(h string) (ID, error) {
+ t := ID{}
+ if len(h) != 32 {
+ return t, ErrInvalidTraceIDLength
+ }
+
+ if err := decodeHex(h, t[:]); err != nil {
+ return t, err
+ }
+
+ if !t.IsValid() {
+ return t, ErrNilTraceID
+ }
+ return t, nil
+}
+
+// SpanIDFromHex returns a SpanID from a hex string if it is compliant
+// with the w3c trace-context specification.
+// See more at https://www.w3.org/TR/trace-context/#parent-id
+func SpanIDFromHex(h string) (SpanID, error) {
+ s := SpanID{}
+ if len(h) != 16 {
+ return s, ErrInvalidSpanIDLength
+ }
+
+ if err := decodeHex(h, s[:]); err != nil {
+ return s, err
+ }
+
+ if !s.IsValid() {
+ return s, ErrNilSpanID
+ }
+ return s, nil
+}
+
+func decodeHex(h string, b []byte) error {
+ for _, r := range h {
+ switch {
+ case 'a' <= r && r <= 'f':
+ continue
+ case '0' <= r && r <= '9':
+ continue
+ default:
+ return ErrInvalidHexID
+ }
+ }
+
+ decoded, err := hex.DecodeString(h)
+ if err != nil {
+ return err
+ }
+
+ copy(b, decoded)
+ return nil
+}
+
+// SpanContext contains basic information about the span - its trace
+// ID, span ID and trace flags.
+type SpanContext struct {
+ TraceID ID
+ SpanID SpanID
+ TraceFlags byte
+}
+
+// EmptySpanContext is meant for internal use to return invalid span
+// context during error conditions.
+func EmptySpanContext() SpanContext {
+ return SpanContext{}
+}
+
+// IsValid checks if the span context is valid. A valid span context
+// has a valid trace ID and a valid span ID.
+func (sc SpanContext) IsValid() bool {
+ return sc.HasTraceID() && sc.HasSpanID()
+}
+
+// HasTraceID checks if the span context has a valid trace ID.
+func (sc SpanContext) HasTraceID() bool {
+ return sc.TraceID.IsValid()
+}
+
+// HasSpanID checks if the span context has a valid span ID.
+func (sc SpanContext) HasSpanID() bool {
+ return sc.SpanID.IsValid()
+}
+
+// IsDeferred returns if the deferred bit is set in the trace flags.
+func (sc SpanContext) IsDeferred() bool {
+ return sc.TraceFlags&FlagsDeferred == FlagsDeferred
+}
+
+// IsDebug returns if the debug bit is set in the trace flags.
+func (sc SpanContext) IsDebug() bool {
+ return sc.TraceFlags&FlagsDebug == FlagsDebug
+}
+
+// IsSampled returns if the sampling bit is set in the trace flags.
+func (sc SpanContext) IsSampled() bool {
+ return sc.TraceFlags&FlagsSampled == FlagsSampled
+}