mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-25 04:38:03 +08:00
vendor: update buildkit to 539be170
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
59
vendor/go.opentelemetry.io/otel/metric/config.go
generated
vendored
59
vendor/go.opentelemetry.io/otel/metric/config.go
generated
vendored
@@ -20,10 +20,8 @@ import (
|
||||
|
||||
// InstrumentConfig contains options for metric instrument descriptors.
|
||||
type InstrumentConfig struct {
|
||||
description string
|
||||
unit unit.Unit
|
||||
instrumentationName string
|
||||
instrumentationVersion string
|
||||
description string
|
||||
unit unit.Unit
|
||||
}
|
||||
|
||||
// Description describes the instrument in human-readable terms.
|
||||
@@ -36,18 +34,6 @@ func (cfg InstrumentConfig) Unit() unit.Unit {
|
||||
return cfg.unit
|
||||
}
|
||||
|
||||
// InstrumentationName is the name of the library providing
|
||||
// instrumentation.
|
||||
func (cfg InstrumentConfig) InstrumentationName() string {
|
||||
return cfg.instrumentationName
|
||||
}
|
||||
|
||||
// InstrumentationVersion is the version of the library providing
|
||||
// instrumentation.
|
||||
func (cfg InstrumentConfig) InstrumentationVersion() string {
|
||||
return cfg.instrumentationVersion
|
||||
}
|
||||
|
||||
// InstrumentOption is an interface for applying metric instrument options.
|
||||
type InstrumentOption interface {
|
||||
// ApplyMeter is used to set a InstrumentOption value of a
|
||||
@@ -85,16 +71,10 @@ func WithUnit(unit unit.Unit) InstrumentOption {
|
||||
})
|
||||
}
|
||||
|
||||
// WithInstrumentationName sets the instrumentation name.
|
||||
func WithInstrumentationName(name string) InstrumentOption {
|
||||
return instrumentOptionFunc(func(cfg *InstrumentConfig) {
|
||||
cfg.instrumentationName = name
|
||||
})
|
||||
}
|
||||
|
||||
// MeterConfig contains options for Meters.
|
||||
type MeterConfig struct {
|
||||
instrumentationVersion string
|
||||
schemaURL string
|
||||
}
|
||||
|
||||
// InstrumentationVersion is the version of the library providing instrumentation.
|
||||
@@ -102,6 +82,11 @@ func (cfg MeterConfig) InstrumentationVersion() string {
|
||||
return cfg.instrumentationVersion
|
||||
}
|
||||
|
||||
// SchemaURL is the schema_url of the library providing instrumentation.
|
||||
func (cfg MeterConfig) SchemaURL() string {
|
||||
return cfg.schemaURL
|
||||
}
|
||||
|
||||
// MeterOption is an interface for applying Meter options.
|
||||
type MeterOption interface {
|
||||
// ApplyMeter is used to set a MeterOption value of a MeterConfig.
|
||||
@@ -118,24 +103,22 @@ func NewMeterConfig(opts ...MeterOption) MeterConfig {
|
||||
return config
|
||||
}
|
||||
|
||||
// InstrumentMeterOption are options that can be used as both an InstrumentOption
|
||||
// and MeterOption
|
||||
type InstrumentMeterOption interface {
|
||||
InstrumentOption
|
||||
MeterOption
|
||||
type meterOptionFunc func(*MeterConfig)
|
||||
|
||||
func (fn meterOptionFunc) applyMeter(cfg *MeterConfig) {
|
||||
fn(cfg)
|
||||
}
|
||||
|
||||
// WithInstrumentationVersion sets the instrumentation version.
|
||||
func WithInstrumentationVersion(version string) InstrumentMeterOption {
|
||||
return instrumentationVersionOption(version)
|
||||
func WithInstrumentationVersion(version string) MeterOption {
|
||||
return meterOptionFunc(func(config *MeterConfig) {
|
||||
config.instrumentationVersion = version
|
||||
})
|
||||
}
|
||||
|
||||
type instrumentationVersionOption string
|
||||
|
||||
func (i instrumentationVersionOption) applyMeter(config *MeterConfig) {
|
||||
config.instrumentationVersion = string(i)
|
||||
}
|
||||
|
||||
func (i instrumentationVersionOption) applyInstrument(config *InstrumentConfig) {
|
||||
config.instrumentationVersion = string(i)
|
||||
// WithSchemaURL sets the schema URL.
|
||||
func WithSchemaURL(schemaURL string) MeterOption {
|
||||
return meterOptionFunc(func(config *MeterConfig) {
|
||||
config.schemaURL = schemaURL
|
||||
})
|
||||
}
|
||||
|
16
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
16
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
@@ -31,23 +31,23 @@ part of a system is being measured.
|
||||
Instruments are categorized as Synchronous or Asynchronous and independently
|
||||
as Adding or Grouping. 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. Grouping
|
||||
Adding instruments are semantically intended for capturing a sum. Grouping
|
||||
instruments are intended for capturing a distribution.
|
||||
|
||||
Additive instruments may be monotonic, in which case they are non-decreasing
|
||||
Adding instruments may be monotonic, in which case they are non-decreasing
|
||||
and naturally define a rate.
|
||||
|
||||
The synchronous instrument names are:
|
||||
|
||||
Counter: additive, monotonic
|
||||
UpDownCounter: additive
|
||||
ValueRecorder: grouping
|
||||
Counter: adding, monotonic
|
||||
UpDownCounter: adding
|
||||
Histogram: grouping
|
||||
|
||||
and the asynchronous instruments are:
|
||||
|
||||
SumObserver: additive, monotonic
|
||||
UpDownSumObserver: additive
|
||||
ValueObserver: grouping
|
||||
CounterObserver: adding, monotonic
|
||||
UpDownCounterObserver: adding
|
||||
GaugeObserver: grouping
|
||||
|
||||
All instruments are provided with support for either float64 or int64 input
|
||||
values.
|
||||
|
18
vendor/go.opentelemetry.io/otel/metric/go.mod
generated
vendored
18
vendor/go.opentelemetry.io/otel/metric/go.mod
generated
vendored
@@ -32,8 +32,6 @@ replace go.opentelemetry.io/otel/internal/tools => ../internal/tools
|
||||
|
||||
replace go.opentelemetry.io/otel/metric => ./
|
||||
|
||||
replace go.opentelemetry.io/otel/oteltest => ../oteltest
|
||||
|
||||
replace go.opentelemetry.io/otel/sdk => ../sdk
|
||||
|
||||
replace go.opentelemetry.io/otel/sdk/export/metric => ../sdk/export/metric
|
||||
@@ -45,8 +43,8 @@ replace go.opentelemetry.io/otel/trace => ../trace
|
||||
require (
|
||||
github.com/google/go-cmp v0.5.6
|
||||
github.com/stretchr/testify v1.7.0
|
||||
go.opentelemetry.io/otel v1.0.0-RC1
|
||||
go.opentelemetry.io/otel/internal/metric v0.21.0
|
||||
go.opentelemetry.io/otel v1.0.1
|
||||
go.opentelemetry.io/otel/internal/metric v0.24.0
|
||||
)
|
||||
|
||||
replace go.opentelemetry.io/otel/example/passthrough => ../example/passthrough
|
||||
@@ -59,12 +57,6 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp => ../ex
|
||||
|
||||
replace go.opentelemetry.io/otel/internal/metric => ../internal/metric
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/metric/prometheus => ../exporters/metric/prometheus
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/trace/jaeger => ../exporters/trace/jaeger
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/trace/zipkin => ../exporters/trace/zipkin
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric => ../exporters/otlp/otlpmetric
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../exporters/otlp/otlpmetric/otlpmetricgrpc
|
||||
@@ -72,3 +64,9 @@ replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc => ../
|
||||
replace go.opentelemetry.io/otel/exporters/stdout/stdoutmetric => ../exporters/stdout/stdoutmetric
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/stdout/stdouttrace => ../exporters/stdout/stdouttrace
|
||||
|
||||
replace go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp => ../exporters/otlp/otlpmetric/otlpmetrichttp
|
||||
|
||||
replace go.opentelemetry.io/otel/bridge/opencensus/test => ../bridge/opencensus/test
|
||||
|
||||
replace go.opentelemetry.io/otel/example/fib => ../example/fib
|
||||
|
274
vendor/go.opentelemetry.io/otel/metric/metric.go
generated
vendored
274
vendor/go.opentelemetry.io/otel/metric/metric.go
generated
vendored
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
"go.opentelemetry.io/otel/metric/sdkapi"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
)
|
||||
|
||||
@@ -37,8 +38,7 @@ type MeterProvider interface {
|
||||
//
|
||||
// An uninitialized Meter is a no-op implementation.
|
||||
type Meter struct {
|
||||
impl MeterImpl
|
||||
name, version string
|
||||
impl MeterImpl
|
||||
}
|
||||
|
||||
// RecordBatch atomically records a batch of measurements.
|
||||
@@ -64,7 +64,7 @@ func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver {
|
||||
// duplicate registration).
|
||||
func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error) {
|
||||
return wrapInt64CounterInstrument(
|
||||
m.newSync(name, CounterInstrumentKind, number.Int64Kind, options))
|
||||
m.newSync(name, sdkapi.CounterInstrumentKind, number.Int64Kind, options))
|
||||
}
|
||||
|
||||
// NewFloat64Counter creates a new floating point Counter with the
|
||||
@@ -73,7 +73,7 @@ func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64C
|
||||
// duplicate registration).
|
||||
func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error) {
|
||||
return wrapFloat64CounterInstrument(
|
||||
m.newSync(name, CounterInstrumentKind, number.Float64Kind, options))
|
||||
m.newSync(name, sdkapi.CounterInstrumentKind, number.Float64Kind, options))
|
||||
}
|
||||
|
||||
// NewInt64UpDownCounter creates a new integer UpDownCounter instrument with the
|
||||
@@ -82,7 +82,7 @@ func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Floa
|
||||
// duplicate registration).
|
||||
func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error) {
|
||||
return wrapInt64UpDownCounterInstrument(
|
||||
m.newSync(name, UpDownCounterInstrumentKind, number.Int64Kind, options))
|
||||
m.newSync(name, sdkapi.UpDownCounterInstrumentKind, number.Int64Kind, options))
|
||||
}
|
||||
|
||||
// NewFloat64UpDownCounter creates a new floating point UpDownCounter with the
|
||||
@@ -91,177 +91,177 @@ func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (
|
||||
// duplicate registration).
|
||||
func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error) {
|
||||
return wrapFloat64UpDownCounterInstrument(
|
||||
m.newSync(name, UpDownCounterInstrumentKind, number.Float64Kind, options))
|
||||
m.newSync(name, sdkapi.UpDownCounterInstrumentKind, number.Float64Kind, options))
|
||||
}
|
||||
|
||||
// NewInt64ValueRecorder creates a new integer ValueRecorder instrument with the
|
||||
// NewInt64Histogram creates a new integer Histogram 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, ValueRecorderInstrumentKind, number.Int64Kind, opts))
|
||||
func (m Meter) NewInt64Histogram(name string, opts ...InstrumentOption) (Int64Histogram, error) {
|
||||
return wrapInt64HistogramInstrument(
|
||||
m.newSync(name, sdkapi.HistogramInstrumentKind, number.Int64Kind, opts))
|
||||
}
|
||||
|
||||
// NewFloat64ValueRecorder creates a new floating point ValueRecorder with the
|
||||
// NewFloat64Histogram creates a new floating point Histogram 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, ValueRecorderInstrumentKind, number.Float64Kind, opts))
|
||||
func (m Meter) NewFloat64Histogram(name string, opts ...InstrumentOption) (Float64Histogram, error) {
|
||||
return wrapFloat64HistogramInstrument(
|
||||
m.newSync(name, sdkapi.HistogramInstrumentKind, number.Float64Kind, opts))
|
||||
}
|
||||
|
||||
// NewInt64ValueObserver creates a new integer ValueObserver instrument
|
||||
// NewInt64GaugeObserver creates a new integer GaugeObserver 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) {
|
||||
func (m Meter) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64GaugeObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64GaugeObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64ValueObserverInstrument(
|
||||
m.newAsync(name, ValueObserverInstrumentKind, number.Int64Kind, opts,
|
||||
return wrapInt64GaugeObserverInstrument(
|
||||
m.newAsync(name, sdkapi.GaugeObserverInstrumentKind, number.Int64Kind, opts,
|
||||
newInt64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewFloat64ValueObserver creates a new floating point ValueObserver with
|
||||
// NewFloat64GaugeObserver creates a new floating point GaugeObserver 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) {
|
||||
func (m Meter) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64GaugeObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64GaugeObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64ValueObserverInstrument(
|
||||
m.newAsync(name, ValueObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64GaugeObserverInstrument(
|
||||
m.newAsync(name, sdkapi.GaugeObserverInstrumentKind, number.Float64Kind, opts,
|
||||
newFloat64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewInt64SumObserver creates a new integer SumObserver instrument
|
||||
// NewInt64CounterObserver creates a new integer CounterObserver 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) {
|
||||
func (m Meter) NewInt64CounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64CounterObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64CounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64SumObserverInstrument(
|
||||
m.newAsync(name, SumObserverInstrumentKind, number.Int64Kind, opts,
|
||||
return wrapInt64CounterObserverInstrument(
|
||||
m.newAsync(name, sdkapi.CounterObserverInstrumentKind, number.Int64Kind, opts,
|
||||
newInt64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewFloat64SumObserver creates a new floating point SumObserver with
|
||||
// NewFloat64CounterObserver creates a new floating point CounterObserver 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) {
|
||||
func (m Meter) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64CounterObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64CounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64SumObserverInstrument(
|
||||
m.newAsync(name, SumObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64CounterObserverInstrument(
|
||||
m.newAsync(name, sdkapi.CounterObserverInstrumentKind, number.Float64Kind, opts,
|
||||
newFloat64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument
|
||||
// NewInt64UpDownCounterObserver creates a new integer UpDownCounterObserver 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) {
|
||||
func (m Meter) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownCounterObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64UpDownCounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64UpDownSumObserverInstrument(
|
||||
m.newAsync(name, UpDownSumObserverInstrumentKind, number.Int64Kind, opts,
|
||||
return wrapInt64UpDownCounterObserverInstrument(
|
||||
m.newAsync(name, sdkapi.UpDownCounterObserverInstrumentKind, number.Int64Kind, opts,
|
||||
newInt64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
|
||||
// NewFloat64UpDownCounterObserver creates a new floating point UpDownCounterObserver 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) {
|
||||
func (m Meter) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownCounterObserver, error) {
|
||||
if callback == nil {
|
||||
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64UpDownCounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64UpDownSumObserverInstrument(
|
||||
m.newAsync(name, UpDownSumObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64UpDownCounterObserverInstrument(
|
||||
m.newAsync(name, sdkapi.UpDownCounterObserverInstrumentKind, number.Float64Kind, opts,
|
||||
newFloat64AsyncRunner(callback)))
|
||||
}
|
||||
|
||||
// NewInt64ValueObserver creates a new integer ValueObserver instrument
|
||||
// NewInt64GaugeObserver creates a new integer GaugeObserver 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) {
|
||||
func (b BatchObserver) NewInt64GaugeObserver(name string, opts ...InstrumentOption) (Int64GaugeObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapInt64ValueObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64GaugeObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64ValueObserverInstrument(
|
||||
b.meter.newAsync(name, ValueObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
return wrapInt64GaugeObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.GaugeObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
}
|
||||
|
||||
// NewFloat64ValueObserver creates a new floating point ValueObserver with
|
||||
// NewFloat64GaugeObserver creates a new floating point GaugeObserver 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) {
|
||||
func (b BatchObserver) NewFloat64GaugeObserver(name string, opts ...InstrumentOption) (Float64GaugeObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapFloat64ValueObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64GaugeObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64ValueObserverInstrument(
|
||||
b.meter.newAsync(name, ValueObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64GaugeObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.GaugeObserverInstrumentKind, number.Float64Kind, opts,
|
||||
b.runner))
|
||||
}
|
||||
|
||||
// NewInt64SumObserver creates a new integer SumObserver instrument
|
||||
// NewInt64CounterObserver creates a new integer CounterObserver 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) {
|
||||
func (b BatchObserver) NewInt64CounterObserver(name string, opts ...InstrumentOption) (Int64CounterObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapInt64SumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64CounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64SumObserverInstrument(
|
||||
b.meter.newAsync(name, SumObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
return wrapInt64CounterObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.CounterObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
}
|
||||
|
||||
// NewFloat64SumObserver creates a new floating point SumObserver with
|
||||
// NewFloat64CounterObserver creates a new floating point CounterObserver 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) {
|
||||
func (b BatchObserver) NewFloat64CounterObserver(name string, opts ...InstrumentOption) (Float64CounterObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapFloat64SumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64CounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64SumObserverInstrument(
|
||||
b.meter.newAsync(name, SumObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64CounterObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.CounterObserverInstrumentKind, number.Float64Kind, opts,
|
||||
b.runner))
|
||||
}
|
||||
|
||||
// NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument
|
||||
// NewInt64UpDownCounterObserver creates a new integer UpDownCounterObserver 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) {
|
||||
func (b BatchObserver) NewInt64UpDownCounterObserver(name string, opts ...InstrumentOption) (Int64UpDownCounterObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapInt64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapInt64UpDownCounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapInt64UpDownSumObserverInstrument(
|
||||
b.meter.newAsync(name, UpDownSumObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
return wrapInt64UpDownCounterObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.UpDownCounterObserverInstrumentKind, number.Int64Kind, opts, b.runner))
|
||||
}
|
||||
|
||||
// NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with
|
||||
// NewFloat64UpDownCounterObserver creates a new floating point UpDownCounterObserver 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) {
|
||||
func (b BatchObserver) NewFloat64UpDownCounterObserver(name string, opts ...InstrumentOption) (Float64UpDownCounterObserver, error) {
|
||||
if b.runner == nil {
|
||||
return wrapFloat64UpDownSumObserverInstrument(NoopAsync{}, nil)
|
||||
return wrapFloat64UpDownCounterObserverInstrument(NoopAsync{}, nil)
|
||||
}
|
||||
return wrapFloat64UpDownSumObserverInstrument(
|
||||
b.meter.newAsync(name, UpDownSumObserverInstrumentKind, number.Float64Kind, opts,
|
||||
return wrapFloat64UpDownCounterObserverInstrument(
|
||||
b.meter.newAsync(name, sdkapi.UpDownCounterObserverInstrumentKind, number.Float64Kind, opts,
|
||||
b.runner))
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ func (m Meter) MeterImpl() MeterImpl {
|
||||
// newAsync constructs one new asynchronous instrument.
|
||||
func (m Meter) newAsync(
|
||||
name string,
|
||||
mkind InstrumentKind,
|
||||
mkind sdkapi.InstrumentKind,
|
||||
nkind number.Kind,
|
||||
opts []InstrumentOption,
|
||||
runner AsyncRunner,
|
||||
@@ -284,16 +284,15 @@ func (m Meter) newAsync(
|
||||
if m.impl == nil {
|
||||
return NoopAsync{}, nil
|
||||
}
|
||||
desc := NewDescriptor(name, mkind, nkind, opts...)
|
||||
desc.config.instrumentationName = m.name
|
||||
desc.config.instrumentationVersion = m.version
|
||||
cfg := NewInstrumentConfig(opts...)
|
||||
desc := NewDescriptor(name, mkind, nkind, cfg.description, cfg.unit)
|
||||
return m.impl.NewAsyncInstrument(desc, runner)
|
||||
}
|
||||
|
||||
// newSync constructs one new synchronous instrument.
|
||||
func (m Meter) newSync(
|
||||
name string,
|
||||
metricKind InstrumentKind,
|
||||
metricKind sdkapi.InstrumentKind,
|
||||
numberKind number.Kind,
|
||||
opts []InstrumentOption,
|
||||
) (
|
||||
@@ -303,9 +302,8 @@ func (m Meter) newSync(
|
||||
if m.impl == nil {
|
||||
return NoopSync{}, nil
|
||||
}
|
||||
desc := NewDescriptor(name, metricKind, numberKind, opts...)
|
||||
desc.config.instrumentationName = m.name
|
||||
desc.config.instrumentationVersion = m.version
|
||||
cfg := NewInstrumentConfig(opts...)
|
||||
desc := NewDescriptor(name, metricKind, numberKind, cfg.description, cfg.unit)
|
||||
return m.impl.NewSyncInstrument(desc)
|
||||
}
|
||||
|
||||
@@ -368,80 +366,80 @@ func (mm MeterMust) NewFloat64UpDownCounter(name string, cos ...InstrumentOption
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64ValueRecorder calls `Meter.NewInt64ValueRecorder` and returns the
|
||||
// NewInt64Histogram calls `Meter.NewInt64Histogram` 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 {
|
||||
func (mm MeterMust) NewInt64Histogram(name string, mos ...InstrumentOption) Int64Histogram {
|
||||
if inst, err := mm.meter.NewInt64Histogram(name, mos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64ValueRecorder calls `Meter.NewFloat64ValueRecorder` and returns the
|
||||
// NewFloat64Histogram calls `Meter.NewFloat64Histogram` 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 {
|
||||
func (mm MeterMust) NewFloat64Histogram(name string, mos ...InstrumentOption) Float64Histogram {
|
||||
if inst, err := mm.meter.NewFloat64Histogram(name, mos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64ValueObserver calls `Meter.NewInt64ValueObserver` and
|
||||
// NewInt64GaugeObserver calls `Meter.NewInt64GaugeObserver` 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 {
|
||||
func (mm MeterMust) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64GaugeObserver {
|
||||
if inst, err := mm.meter.NewInt64GaugeObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64ValueObserver calls `Meter.NewFloat64ValueObserver` and
|
||||
// NewFloat64GaugeObserver calls `Meter.NewFloat64GaugeObserver` 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 {
|
||||
func (mm MeterMust) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64GaugeObserver {
|
||||
if inst, err := mm.meter.NewFloat64GaugeObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64SumObserver calls `Meter.NewInt64SumObserver` and
|
||||
// NewInt64CounterObserver calls `Meter.NewInt64CounterObserver` 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 {
|
||||
func (mm MeterMust) NewInt64CounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64CounterObserver {
|
||||
if inst, err := mm.meter.NewInt64CounterObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64SumObserver calls `Meter.NewFloat64SumObserver` and
|
||||
// NewFloat64CounterObserver calls `Meter.NewFloat64CounterObserver` 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 {
|
||||
func (mm MeterMust) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64CounterObserver {
|
||||
if inst, err := mm.meter.NewFloat64CounterObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64UpDownSumObserver calls `Meter.NewInt64UpDownSumObserver` and
|
||||
// NewInt64UpDownCounterObserver calls `Meter.NewInt64UpDownCounterObserver` 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 {
|
||||
func (mm MeterMust) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownCounterObserver {
|
||||
if inst, err := mm.meter.NewInt64UpDownCounterObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64UpDownSumObserver calls `Meter.NewFloat64UpDownSumObserver` and
|
||||
// NewFloat64UpDownCounterObserver calls `Meter.NewFloat64UpDownCounterObserver` 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 {
|
||||
func (mm MeterMust) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownCounterObserver {
|
||||
if inst, err := mm.meter.NewFloat64UpDownCounterObserver(name, callback, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
@@ -456,60 +454,60 @@ func (mm MeterMust) NewBatchObserver(callback BatchObserverFunc) BatchObserverMu
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64ValueObserver calls `BatchObserver.NewInt64ValueObserver` and
|
||||
// NewInt64GaugeObserver calls `BatchObserver.NewInt64GaugeObserver` 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 {
|
||||
func (bm BatchObserverMust) NewInt64GaugeObserver(name string, oos ...InstrumentOption) Int64GaugeObserver {
|
||||
if inst, err := bm.batch.NewInt64GaugeObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64ValueObserver calls `BatchObserver.NewFloat64ValueObserver` and
|
||||
// NewFloat64GaugeObserver calls `BatchObserver.NewFloat64GaugeObserver` 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 {
|
||||
func (bm BatchObserverMust) NewFloat64GaugeObserver(name string, oos ...InstrumentOption) Float64GaugeObserver {
|
||||
if inst, err := bm.batch.NewFloat64GaugeObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64SumObserver calls `BatchObserver.NewInt64SumObserver` and
|
||||
// NewInt64CounterObserver calls `BatchObserver.NewInt64CounterObserver` 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 {
|
||||
func (bm BatchObserverMust) NewInt64CounterObserver(name string, oos ...InstrumentOption) Int64CounterObserver {
|
||||
if inst, err := bm.batch.NewInt64CounterObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64SumObserver calls `BatchObserver.NewFloat64SumObserver` and
|
||||
// NewFloat64CounterObserver calls `BatchObserver.NewFloat64CounterObserver` 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 {
|
||||
func (bm BatchObserverMust) NewFloat64CounterObserver(name string, oos ...InstrumentOption) Float64CounterObserver {
|
||||
if inst, err := bm.batch.NewFloat64CounterObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewInt64UpDownSumObserver calls `BatchObserver.NewInt64UpDownSumObserver` and
|
||||
// NewInt64UpDownCounterObserver calls `BatchObserver.NewInt64UpDownCounterObserver` 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 {
|
||||
func (bm BatchObserverMust) NewInt64UpDownCounterObserver(name string, oos ...InstrumentOption) Int64UpDownCounterObserver {
|
||||
if inst, err := bm.batch.NewInt64UpDownCounterObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
}
|
||||
}
|
||||
|
||||
// NewFloat64UpDownSumObserver calls `BatchObserver.NewFloat64UpDownSumObserver` and
|
||||
// NewFloat64UpDownCounterObserver calls `BatchObserver.NewFloat64UpDownCounterObserver` 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 {
|
||||
func (bm BatchObserverMust) NewFloat64UpDownCounterObserver(name string, oos ...InstrumentOption) Float64UpDownCounterObserver {
|
||||
if inst, err := bm.batch.NewFloat64UpDownCounterObserver(name, oos...); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
return inst
|
||||
@@ -521,18 +519,20 @@ func (bm BatchObserverMust) NewFloat64UpDownSumObserver(name string, oos ...Inst
|
||||
// options.
|
||||
type Descriptor struct {
|
||||
name string
|
||||
instrumentKind InstrumentKind
|
||||
instrumentKind sdkapi.InstrumentKind
|
||||
numberKind number.Kind
|
||||
config InstrumentConfig
|
||||
description string
|
||||
unit unit.Unit
|
||||
}
|
||||
|
||||
// NewDescriptor returns a Descriptor with the given contents.
|
||||
func NewDescriptor(name string, ikind InstrumentKind, nkind number.Kind, opts ...InstrumentOption) Descriptor {
|
||||
func NewDescriptor(name string, ikind sdkapi.InstrumentKind, nkind number.Kind, description string, unit unit.Unit) Descriptor {
|
||||
return Descriptor{
|
||||
name: name,
|
||||
instrumentKind: ikind,
|
||||
numberKind: nkind,
|
||||
config: NewInstrumentConfig(opts...),
|
||||
description: description,
|
||||
unit: unit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,20 +542,20 @@ func (d Descriptor) Name() string {
|
||||
}
|
||||
|
||||
// InstrumentKind returns the specific kind of instrument.
|
||||
func (d Descriptor) InstrumentKind() InstrumentKind {
|
||||
func (d Descriptor) InstrumentKind() sdkapi.InstrumentKind {
|
||||
return d.instrumentKind
|
||||
}
|
||||
|
||||
// Description provides a human-readable description of the metric
|
||||
// instrument.
|
||||
func (d Descriptor) Description() string {
|
||||
return d.config.Description()
|
||||
return d.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()
|
||||
return d.unit
|
||||
}
|
||||
|
||||
// NumberKind returns whether this instrument is declared over int64,
|
||||
@@ -563,15 +563,3 @@ func (d Descriptor) Unit() unit.Unit {
|
||||
func (d Descriptor) NumberKind() number.Kind {
|
||||
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()
|
||||
}
|
||||
|
199
vendor/go.opentelemetry.io/otel/metric/metric_instrument.go
generated
vendored
199
vendor/go.opentelemetry.io/otel/metric/metric_instrument.go
generated
vendored
@@ -12,8 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:generate stringer -type=InstrumentKind
|
||||
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
@@ -27,72 +25,9 @@ import (
|
||||
// ErrSDKReturnedNilImpl is returned when a new `MeterImpl` returns nil.
|
||||
var ErrSDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
|
||||
|
||||
// InstrumentKind describes the kind of instrument.
|
||||
type InstrumentKind int8
|
||||
|
||||
const (
|
||||
// ValueRecorderInstrumentKind indicates a ValueRecorder instrument.
|
||||
ValueRecorderInstrumentKind InstrumentKind = iota
|
||||
// ValueObserverInstrumentKind indicates an ValueObserver instrument.
|
||||
ValueObserverInstrumentKind
|
||||
|
||||
// CounterInstrumentKind indicates a Counter instrument.
|
||||
CounterInstrumentKind
|
||||
// UpDownCounterInstrumentKind indicates a UpDownCounter instrument.
|
||||
UpDownCounterInstrumentKind
|
||||
|
||||
// SumObserverInstrumentKind indicates a SumObserver instrument.
|
||||
SumObserverInstrumentKind
|
||||
// UpDownSumObserverInstrumentKind indicates a UpDownSumObserver
|
||||
// instrument.
|
||||
UpDownSumObserverInstrumentKind
|
||||
)
|
||||
|
||||
// Synchronous returns whether this is a synchronous kind of instrument.
|
||||
func (k InstrumentKind) Synchronous() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, UpDownCounterInstrumentKind, ValueRecorderInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Asynchronous returns whether this is an asynchronous kind of instrument.
|
||||
func (k InstrumentKind) Asynchronous() bool {
|
||||
return !k.Synchronous()
|
||||
}
|
||||
|
||||
// Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).
|
||||
func (k InstrumentKind) Adding() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, UpDownCounterInstrumentKind, SumObserverInstrumentKind, UpDownSumObserverInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Grouping returns whether this kind of instrument groups its inputs (as opposed to Adding).
|
||||
func (k InstrumentKind) Grouping() bool {
|
||||
return !k.Adding()
|
||||
}
|
||||
|
||||
// Monotonic returns whether this kind of instrument exposes a non-decreasing sum.
|
||||
func (k InstrumentKind) Monotonic() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, SumObserverInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// PrecomputedSum returns whether this kind of instrument receives precomputed sums.
|
||||
func (k InstrumentKind) PrecomputedSum() bool {
|
||||
return k.Adding() && k.Asynchronous()
|
||||
}
|
||||
|
||||
// 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()).
|
||||
// instruments (e.g., Int64GaugeObserver.Observation()).
|
||||
type Observation struct {
|
||||
// number needs to be aligned for 64-bit atomic operations.
|
||||
number number.Number
|
||||
@@ -239,40 +174,40 @@ func (b *BatchObserverFunc) Run(ctx context.Context, function func([]attribute.K
|
||||
})
|
||||
}
|
||||
|
||||
// wrapInt64ValueObserverInstrument converts an AsyncImpl into Int64ValueObserver.
|
||||
func wrapInt64ValueObserverInstrument(asyncInst AsyncImpl, err error) (Int64ValueObserver, error) {
|
||||
// wrapInt64GaugeObserverInstrument converts an AsyncImpl into Int64GaugeObserver.
|
||||
func wrapInt64GaugeObserverInstrument(asyncInst AsyncImpl, err error) (Int64GaugeObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Int64ValueObserver{asyncInstrument: common}, err
|
||||
return Int64GaugeObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapFloat64ValueObserverInstrument converts an AsyncImpl into Float64ValueObserver.
|
||||
func wrapFloat64ValueObserverInstrument(asyncInst AsyncImpl, err error) (Float64ValueObserver, error) {
|
||||
// wrapFloat64GaugeObserverInstrument converts an AsyncImpl into Float64GaugeObserver.
|
||||
func wrapFloat64GaugeObserverInstrument(asyncInst AsyncImpl, err error) (Float64GaugeObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Float64ValueObserver{asyncInstrument: common}, err
|
||||
return Float64GaugeObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapInt64SumObserverInstrument converts an AsyncImpl into Int64SumObserver.
|
||||
func wrapInt64SumObserverInstrument(asyncInst AsyncImpl, err error) (Int64SumObserver, error) {
|
||||
// wrapInt64CounterObserverInstrument converts an AsyncImpl into Int64CounterObserver.
|
||||
func wrapInt64CounterObserverInstrument(asyncInst AsyncImpl, err error) (Int64CounterObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Int64SumObserver{asyncInstrument: common}, err
|
||||
return Int64CounterObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapFloat64SumObserverInstrument converts an AsyncImpl into Float64SumObserver.
|
||||
func wrapFloat64SumObserverInstrument(asyncInst AsyncImpl, err error) (Float64SumObserver, error) {
|
||||
// wrapFloat64CounterObserverInstrument converts an AsyncImpl into Float64CounterObserver.
|
||||
func wrapFloat64CounterObserverInstrument(asyncInst AsyncImpl, err error) (Float64CounterObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Float64SumObserver{asyncInstrument: common}, err
|
||||
return Float64CounterObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapInt64UpDownSumObserverInstrument converts an AsyncImpl into Int64UpDownSumObserver.
|
||||
func wrapInt64UpDownSumObserverInstrument(asyncInst AsyncImpl, err error) (Int64UpDownSumObserver, error) {
|
||||
// wrapInt64UpDownCounterObserverInstrument converts an AsyncImpl into Int64UpDownCounterObserver.
|
||||
func wrapInt64UpDownCounterObserverInstrument(asyncInst AsyncImpl, err error) (Int64UpDownCounterObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Int64UpDownSumObserver{asyncInstrument: common}, err
|
||||
return Int64UpDownCounterObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapFloat64UpDownSumObserverInstrument converts an AsyncImpl into Float64UpDownSumObserver.
|
||||
func wrapFloat64UpDownSumObserverInstrument(asyncInst AsyncImpl, err error) (Float64UpDownSumObserver, error) {
|
||||
// wrapFloat64UpDownCounterObserverInstrument converts an AsyncImpl into Float64UpDownCounterObserver.
|
||||
func wrapFloat64UpDownCounterObserverInstrument(asyncInst AsyncImpl, err error) (Float64UpDownCounterObserver, error) {
|
||||
common, err := checkNewAsync(asyncInst, err)
|
||||
return Float64UpDownSumObserver{asyncInstrument: common}, err
|
||||
return Float64UpDownCounterObserver{asyncInstrument: common}, err
|
||||
}
|
||||
|
||||
// BatchObserver represents an Observer callback that can report
|
||||
@@ -282,39 +217,39 @@ type BatchObserver struct {
|
||||
runner AsyncBatchRunner
|
||||
}
|
||||
|
||||
// Int64ValueObserver is a metric that captures a set of int64 values at a
|
||||
// Int64GaugeObserver is a metric that captures a set of int64 values at a
|
||||
// point in time.
|
||||
type Int64ValueObserver struct {
|
||||
type Int64GaugeObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
// Float64ValueObserver is a metric that captures a set of float64 values
|
||||
// Float64GaugeObserver is a metric that captures a set of float64 values
|
||||
// at a point in time.
|
||||
type Float64ValueObserver struct {
|
||||
type Float64GaugeObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
// Int64SumObserver is a metric that captures a precomputed sum of
|
||||
// Int64CounterObserver is a metric that captures a precomputed sum of
|
||||
// int64 values at a point in time.
|
||||
type Int64SumObserver struct {
|
||||
type Int64CounterObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
// Float64SumObserver is a metric that captures a precomputed sum of
|
||||
// Float64CounterObserver is a metric that captures a precomputed sum of
|
||||
// float64 values at a point in time.
|
||||
type Float64SumObserver struct {
|
||||
type Float64CounterObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
// Int64UpDownSumObserver is a metric that captures a precomputed sum of
|
||||
// Int64UpDownCounterObserver is a metric that captures a precomputed sum of
|
||||
// int64 values at a point in time.
|
||||
type Int64UpDownSumObserver struct {
|
||||
type Int64UpDownCounterObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
// Float64UpDownSumObserver is a metric that captures a precomputed sum of
|
||||
// Float64UpDownCounterObserver is a metric that captures a precomputed sum of
|
||||
// float64 values at a point in time.
|
||||
type Float64UpDownSumObserver struct {
|
||||
type Float64UpDownCounterObserver struct {
|
||||
asyncInstrument
|
||||
}
|
||||
|
||||
@@ -322,7 +257,7 @@ type Float64UpDownSumObserver struct {
|
||||
// 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 {
|
||||
func (i Int64GaugeObserver) Observation(v int64) Observation {
|
||||
return Observation{
|
||||
number: number.NewInt64Number(v),
|
||||
instrument: i.instrument,
|
||||
@@ -333,7 +268,7 @@ func (i Int64ValueObserver) Observation(v int64) Observation {
|
||||
// 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 {
|
||||
func (f Float64GaugeObserver) Observation(v float64) Observation {
|
||||
return Observation{
|
||||
number: number.NewFloat64Number(v),
|
||||
instrument: f.instrument,
|
||||
@@ -344,7 +279,7 @@ func (f Float64ValueObserver) Observation(v float64) Observation {
|
||||
// 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 {
|
||||
func (i Int64CounterObserver) Observation(v int64) Observation {
|
||||
return Observation{
|
||||
number: number.NewInt64Number(v),
|
||||
instrument: i.instrument,
|
||||
@@ -355,7 +290,7 @@ func (i Int64SumObserver) Observation(v int64) Observation {
|
||||
// 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 {
|
||||
func (f Float64CounterObserver) Observation(v float64) Observation {
|
||||
return Observation{
|
||||
number: number.NewFloat64Number(v),
|
||||
instrument: f.instrument,
|
||||
@@ -366,7 +301,7 @@ func (f Float64SumObserver) Observation(v float64) Observation {
|
||||
// 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 {
|
||||
func (i Int64UpDownCounterObserver) Observation(v int64) Observation {
|
||||
return Observation{
|
||||
number: number.NewInt64Number(v),
|
||||
instrument: i.instrument,
|
||||
@@ -377,7 +312,7 @@ func (i Int64UpDownSumObserver) Observation(v int64) Observation {
|
||||
// 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 {
|
||||
func (f Float64UpDownCounterObserver) Observation(v float64) Observation {
|
||||
return Observation{
|
||||
number: number.NewFloat64Number(v),
|
||||
instrument: f.instrument,
|
||||
@@ -539,16 +474,16 @@ func wrapFloat64UpDownCounterInstrument(syncInst SyncImpl, err error) (Float64Up
|
||||
return Float64UpDownCounter{syncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapInt64ValueRecorderInstrument converts a SyncImpl into Int64ValueRecorder.
|
||||
func wrapInt64ValueRecorderInstrument(syncInst SyncImpl, err error) (Int64ValueRecorder, error) {
|
||||
// wrapInt64HistogramInstrument converts a SyncImpl into Int64Histogram.
|
||||
func wrapInt64HistogramInstrument(syncInst SyncImpl, err error) (Int64Histogram, error) {
|
||||
common, err := checkNewSync(syncInst, err)
|
||||
return Int64ValueRecorder{syncInstrument: common}, err
|
||||
return Int64Histogram{syncInstrument: common}, err
|
||||
}
|
||||
|
||||
// wrapFloat64ValueRecorderInstrument converts a SyncImpl into Float64ValueRecorder.
|
||||
func wrapFloat64ValueRecorderInstrument(syncInst SyncImpl, err error) (Float64ValueRecorder, error) {
|
||||
// wrapFloat64HistogramInstrument converts a SyncImpl into Float64Histogram.
|
||||
func wrapFloat64HistogramInstrument(syncInst SyncImpl, err error) (Float64Histogram, error) {
|
||||
common, err := checkNewSync(syncInst, err)
|
||||
return Float64ValueRecorder{syncInstrument: common}, err
|
||||
return Float64Histogram{syncInstrument: common}, err
|
||||
}
|
||||
|
||||
// Float64Counter is a metric that accumulates float64 values.
|
||||
@@ -700,78 +635,78 @@ func (b BoundInt64UpDownCounter) Add(ctx context.Context, value int64) {
|
||||
b.directRecord(ctx, number.NewInt64Number(value))
|
||||
}
|
||||
|
||||
// Float64ValueRecorder is a metric that records float64 values.
|
||||
type Float64ValueRecorder struct {
|
||||
// Float64Histogram is a metric that records float64 values.
|
||||
type Float64Histogram struct {
|
||||
syncInstrument
|
||||
}
|
||||
|
||||
// Int64ValueRecorder is a metric that records int64 values.
|
||||
type Int64ValueRecorder struct {
|
||||
// Int64Histogram is a metric that records int64 values.
|
||||
type Int64Histogram struct {
|
||||
syncInstrument
|
||||
}
|
||||
|
||||
// BoundFloat64ValueRecorder is a bound instrument for Float64ValueRecorder.
|
||||
// BoundFloat64Histogram is a bound instrument for Float64Histogram.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundFloat64ValueRecorder struct {
|
||||
type BoundFloat64Histogram struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// BoundInt64ValueRecorder is a bound instrument for Int64ValueRecorder.
|
||||
// BoundInt64Histogram is a bound instrument for Int64Histogram.
|
||||
//
|
||||
// It inherits the Unbind function from syncBoundInstrument.
|
||||
type BoundInt64ValueRecorder struct {
|
||||
type BoundInt64Histogram struct {
|
||||
syncBoundInstrument
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this ValueRecorder. The labels are
|
||||
// Bind creates a bound instrument for this Histogram. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Float64ValueRecorder) Bind(labels ...attribute.KeyValue) (h BoundFloat64ValueRecorder) {
|
||||
func (c Float64Histogram) Bind(labels ...attribute.KeyValue) (h BoundFloat64Histogram) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Bind creates a bound instrument for this ValueRecorder. The labels are
|
||||
// Bind creates a bound instrument for this Histogram. The labels are
|
||||
// associated with values recorded via subsequent calls to Record.
|
||||
func (c Int64ValueRecorder) Bind(labels ...attribute.KeyValue) (h BoundInt64ValueRecorder) {
|
||||
func (c Int64Histogram) Bind(labels ...attribute.KeyValue) (h BoundInt64Histogram) {
|
||||
h.syncBoundInstrument = c.bind(labels)
|
||||
return
|
||||
}
|
||||
|
||||
// Measurement creates a Measurement object to use with batch
|
||||
// recording.
|
||||
func (c Float64ValueRecorder) Measurement(value float64) Measurement {
|
||||
func (c Float64Histogram) 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 {
|
||||
func (c Int64Histogram) Measurement(value int64) Measurement {
|
||||
return c.int64Measurement(value)
|
||||
}
|
||||
|
||||
// Record adds a new value to the list of ValueRecorder's records. The
|
||||
// Record adds a new value to the list of Histogram'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 ...attribute.KeyValue) {
|
||||
func (c Float64Histogram) Record(ctx context.Context, value float64, labels ...attribute.KeyValue) {
|
||||
c.directRecord(ctx, number.NewFloat64Number(value), labels)
|
||||
}
|
||||
|
||||
// Record adds a new value to the ValueRecorder's distribution. The
|
||||
// Record adds a new value to the Histogram'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 ...attribute.KeyValue) {
|
||||
func (c Int64Histogram) Record(ctx context.Context, value int64, labels ...attribute.KeyValue) {
|
||||
c.directRecord(ctx, number.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) {
|
||||
// Record adds a new value to the Histogram's distribution using the labels
|
||||
// previously bound to the Histogram via Bind().
|
||||
func (b BoundFloat64Histogram) Record(ctx context.Context, value float64) {
|
||||
b.directRecord(ctx, number.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) {
|
||||
// Record adds a new value to the Histogram's distribution using the labels
|
||||
// previously bound to the Histogram via Bind().
|
||||
func (b BoundInt64Histogram) Record(ctx context.Context, value int64) {
|
||||
b.directRecord(ctx, number.NewInt64Number(value))
|
||||
}
|
||||
|
8
vendor/go.opentelemetry.io/otel/metric/metric_sdkapi.go
generated
vendored
8
vendor/go.opentelemetry.io/otel/metric/metric_sdkapi.go
generated
vendored
@@ -54,7 +54,7 @@ type InstrumentImpl interface {
|
||||
}
|
||||
|
||||
// SyncImpl is the implementation-level interface to a generic
|
||||
// synchronous instrument (e.g., ValueRecorder and Counter instruments).
|
||||
// synchronous instrument (e.g., Histogram and Counter instruments).
|
||||
type SyncImpl interface {
|
||||
InstrumentImpl
|
||||
|
||||
@@ -86,10 +86,8 @@ type AsyncImpl interface {
|
||||
|
||||
// WrapMeterImpl constructs a `Meter` implementation from a
|
||||
// `MeterImpl` implementation.
|
||||
func WrapMeterImpl(impl MeterImpl, instrumentationName string, opts ...MeterOption) Meter {
|
||||
func WrapMeterImpl(impl MeterImpl) Meter {
|
||||
return Meter{
|
||||
impl: impl,
|
||||
name: instrumentationName,
|
||||
version: NewMeterConfig(opts...).InstrumentationVersion(),
|
||||
impl: impl,
|
||||
}
|
||||
}
|
||||
|
@@ -21,19 +21,26 @@ import (
|
||||
"go.opentelemetry.io/otel/metric/number"
|
||||
)
|
||||
|
||||
type NoopMeterProvider struct{}
|
||||
// NewNoopMeterProvider returns an implementation of MeterProvider that
|
||||
// performs no operations. The Meter and Instrument created from the returned
|
||||
// MeterProvider also perform no operations.
|
||||
func NewNoopMeterProvider() MeterProvider {
|
||||
return noopMeterProvider{}
|
||||
}
|
||||
|
||||
type noopMeterProvider struct{}
|
||||
|
||||
type noopInstrument struct{}
|
||||
type noopBoundInstrument struct{}
|
||||
type NoopSync struct{ noopInstrument }
|
||||
type NoopAsync struct{ noopInstrument }
|
||||
|
||||
var _ MeterProvider = NoopMeterProvider{}
|
||||
var _ MeterProvider = noopMeterProvider{}
|
||||
var _ SyncImpl = NoopSync{}
|
||||
var _ BoundSyncImpl = noopBoundInstrument{}
|
||||
var _ AsyncImpl = NoopAsync{}
|
||||
|
||||
func (NoopMeterProvider) Meter(_ string, _ ...MeterOption) Meter {
|
||||
func (noopMeterProvider) Meter(instrumentationName string, opts ...MeterOption) Meter {
|
||||
return Meter{}
|
||||
}
|
||||
|
2
vendor/go.opentelemetry.io/otel/metric/number/kind_string.go
generated
vendored
2
vendor/go.opentelemetry.io/otel/metric/number/kind_string.go
generated
vendored
@@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=Kind"; DO NOT EDIT.
|
||||
|
||||
package number
|
||||
package number // import "go.opentelemetry.io/otel/metric/number"
|
||||
|
||||
import "strconv"
|
||||
|
||||
|
24
vendor/go.opentelemetry.io/otel/metric/registry/doc.go
generated
vendored
24
vendor/go.opentelemetry.io/otel/metric/registry/doc.go
generated
vendored
@@ -1,24 +0,0 @@
|
||||
// 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 provides a non-standalone implementation of
|
||||
MeterProvider that adds uniqueness checking for instrument descriptors
|
||||
on top of other MeterProvider it wraps.
|
||||
|
||||
This package is currently in a pre-GA phase. Backwards incompatible changes
|
||||
may be introduced in subsequent minor version releases as we work to track the
|
||||
evolving OpenTelemetry specification and user feedback.
|
||||
*/
|
||||
package registry // import "go.opentelemetry.io/otel/metric/registry"
|
170
vendor/go.opentelemetry.io/otel/metric/registry/registry.go
generated
vendored
170
vendor/go.opentelemetry.io/otel/metric/registry/registry.go
generated
vendored
@@ -1,170 +0,0 @@
|
||||
// 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/metric/registry"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
// 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 []attribute.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.InstrumentKind(),
|
||||
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.InstrumentKind() == existing.InstrumentKind() &&
|
||||
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
|
||||
}
|
80
vendor/go.opentelemetry.io/otel/metric/sdkapi/instrumentkind.go
generated
vendored
Normal file
80
vendor/go.opentelemetry.io/otel/metric/sdkapi/instrumentkind.go
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
// 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=InstrumentKind
|
||||
|
||||
package sdkapi // import "go.opentelemetry.io/otel/metric/sdkapi"
|
||||
|
||||
// InstrumentKind describes the kind of instrument.
|
||||
type InstrumentKind int8
|
||||
|
||||
const (
|
||||
// HistogramInstrumentKind indicates a Histogram instrument.
|
||||
HistogramInstrumentKind InstrumentKind = iota
|
||||
// GaugeObserverInstrumentKind indicates an GaugeObserver instrument.
|
||||
GaugeObserverInstrumentKind
|
||||
|
||||
// CounterInstrumentKind indicates a Counter instrument.
|
||||
CounterInstrumentKind
|
||||
// UpDownCounterInstrumentKind indicates a UpDownCounter instrument.
|
||||
UpDownCounterInstrumentKind
|
||||
|
||||
// CounterObserverInstrumentKind indicates a CounterObserver instrument.
|
||||
CounterObserverInstrumentKind
|
||||
// UpDownCounterObserverInstrumentKind indicates a UpDownCounterObserver
|
||||
// instrument.
|
||||
UpDownCounterObserverInstrumentKind
|
||||
)
|
||||
|
||||
// Synchronous returns whether this is a synchronous kind of instrument.
|
||||
func (k InstrumentKind) Synchronous() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, UpDownCounterInstrumentKind, HistogramInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Asynchronous returns whether this is an asynchronous kind of instrument.
|
||||
func (k InstrumentKind) Asynchronous() bool {
|
||||
return !k.Synchronous()
|
||||
}
|
||||
|
||||
// Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).
|
||||
func (k InstrumentKind) Adding() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, UpDownCounterInstrumentKind, CounterObserverInstrumentKind, UpDownCounterObserverInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Grouping returns whether this kind of instrument groups its inputs (as opposed to Adding).
|
||||
func (k InstrumentKind) Grouping() bool {
|
||||
return !k.Adding()
|
||||
}
|
||||
|
||||
// Monotonic returns whether this kind of instrument exposes a non-decreasing sum.
|
||||
func (k InstrumentKind) Monotonic() bool {
|
||||
switch k {
|
||||
case CounterInstrumentKind, CounterObserverInstrumentKind:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// PrecomputedSum returns whether this kind of instrument receives precomputed sums.
|
||||
func (k InstrumentKind) PrecomputedSum() bool {
|
||||
return k.Adding() && k.Asynchronous()
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by "stringer -type=InstrumentKind"; DO NOT EDIT.
|
||||
|
||||
package metric
|
||||
package sdkapi // import "go.opentelemetry.io/otel/metric/sdkapi"
|
||||
|
||||
import "strconv"
|
||||
|
||||
@@ -8,17 +8,17 @@ 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[ValueRecorderInstrumentKind-0]
|
||||
_ = x[ValueObserverInstrumentKind-1]
|
||||
_ = x[HistogramInstrumentKind-0]
|
||||
_ = x[GaugeObserverInstrumentKind-1]
|
||||
_ = x[CounterInstrumentKind-2]
|
||||
_ = x[UpDownCounterInstrumentKind-3]
|
||||
_ = x[SumObserverInstrumentKind-4]
|
||||
_ = x[UpDownSumObserverInstrumentKind-5]
|
||||
_ = x[CounterObserverInstrumentKind-4]
|
||||
_ = x[UpDownCounterObserverInstrumentKind-5]
|
||||
}
|
||||
|
||||
const _InstrumentKind_name = "ValueRecorderInstrumentKindValueObserverInstrumentKindCounterInstrumentKindUpDownCounterInstrumentKindSumObserverInstrumentKindUpDownSumObserverInstrumentKind"
|
||||
const _InstrumentKind_name = "HistogramInstrumentKindGaugeObserverInstrumentKindCounterInstrumentKindUpDownCounterInstrumentKindCounterObserverInstrumentKindUpDownCounterObserverInstrumentKind"
|
||||
|
||||
var _InstrumentKind_index = [...]uint8{0, 27, 54, 75, 102, 127, 158}
|
||||
var _InstrumentKind_index = [...]uint8{0, 23, 50, 71, 98, 127, 162}
|
||||
|
||||
func (i InstrumentKind) String() string {
|
||||
if i < 0 || i >= InstrumentKind(len(_InstrumentKind_index)-1) {
|
Reference in New Issue
Block a user