mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 05:02:25 -05:00
[chore] Update a bunch of database dependencies (#1772)
* [chore] Update a bunch of database dependencies * fix lil thing
This commit is contained in:
parent
66df974143
commit
ec325fee14
402 changed files with 35068 additions and 35401 deletions
258
vendor/go.opentelemetry.io/otel/metric/asyncfloat64.go
generated
vendored
Normal file
258
vendor/go.opentelemetry.io/otel/metric/asyncfloat64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
// 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/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Float64Observable describes a set of instruments used asynchronously to
|
||||
// record float64 measurements once per collection cycle. Observations of
|
||||
// these instruments are only made within a callback.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases.
|
||||
type Float64Observable interface {
|
||||
Observable
|
||||
|
||||
float64Observable()
|
||||
}
|
||||
|
||||
// Float64ObservableCounter is an instrument used to asynchronously record
|
||||
// increasing float64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument. The value observed is
|
||||
// assumed the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64ObservableCounter interface {
|
||||
embedded.Float64ObservableCounter
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64ObservableCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableCounterConfig returns a new
|
||||
// [Float64ObservableCounterConfig] with all opts applied.
|
||||
func NewFloat64ObservableCounterConfig(opts ...Float64ObservableCounterOption) Float64ObservableCounterConfig {
|
||||
var config Float64ObservableCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableCounterConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableCounterOption applies options to a
|
||||
// [Float64ObservableCounterConfig]. See [Float64ObservableOption] and [Option]
|
||||
// for other options that can be used as a Float64ObservableCounterOption.
|
||||
type Float64ObservableCounterOption interface {
|
||||
applyFloat64ObservableCounter(Float64ObservableCounterConfig) Float64ObservableCounterConfig
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounter is an instrument used to asynchronously
|
||||
// record float64 measurements once per collection cycle. Observations are only
|
||||
// made within a callback for this instrument. The value observed is assumed
|
||||
// the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64ObservableUpDownCounter interface {
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterConfig contains options for asynchronous
|
||||
// counter instruments that record int64 values.
|
||||
type Float64ObservableUpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableUpDownCounterConfig returns a new
|
||||
// [Float64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewFloat64ObservableUpDownCounterConfig(opts ...Float64ObservableUpDownCounterOption) Float64ObservableUpDownCounterConfig {
|
||||
var config Float64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableUpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableUpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableUpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableUpDownCounterConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterOption applies options to a
|
||||
// [Float64ObservableUpDownCounterConfig]. See [Float64ObservableOption] and
|
||||
// [Option] for other options that can be used as a
|
||||
// Float64ObservableUpDownCounterOption.
|
||||
type Float64ObservableUpDownCounterOption interface {
|
||||
applyFloat64ObservableUpDownCounter(Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig
|
||||
}
|
||||
|
||||
// Float64ObservableGauge is an instrument used to asynchronously record
|
||||
// instantaneous float64 measurements once per collection cycle. Observations
|
||||
// are only made within a callback for this instrument.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64ObservableGauge interface {
|
||||
embedded.Float64ObservableGauge
|
||||
|
||||
Float64Observable
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64ObservableGaugeConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObservableGaugeConfig returns a new [Float64ObservableGaugeConfig]
|
||||
// with all opts applied.
|
||||
func NewFloat64ObservableGaugeConfig(opts ...Float64ObservableGaugeOption) Float64ObservableGaugeConfig {
|
||||
var config Float64ObservableGaugeConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64ObservableGauge(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64ObservableGaugeConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64ObservableGaugeConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Float64ObservableGaugeConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeOption applies options to a
|
||||
// [Float64ObservableGaugeConfig]. See [Float64ObservableOption] and
|
||||
// [Option] for other options that can be used as a
|
||||
// Float64ObservableGaugeOption.
|
||||
type Float64ObservableGaugeOption interface {
|
||||
applyFloat64ObservableGauge(Float64ObservableGaugeConfig) Float64ObservableGaugeConfig
|
||||
}
|
||||
|
||||
// Float64Observer is a recorder of float64 measurements.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64Observer interface {
|
||||
embedded.Float64Observer
|
||||
|
||||
// Observe records the float64 value.
|
||||
Observe(value float64, opts ...ObserveOption)
|
||||
}
|
||||
|
||||
// Float64Callback is a function registered with a Meter that makes
|
||||
// observations for a Float64Observerable instrument it is registered with.
|
||||
// Calls to the Float64Observer record measurement values for the
|
||||
// Float64Observable.
|
||||
//
|
||||
// The function needs to complete in a finite amount of time and the deadline
|
||||
// of the passed context is expected to be honored.
|
||||
//
|
||||
// The function needs to make unique observations across all registered
|
||||
// Float64Callbacks. Meaning, it should not report measurements with the same
|
||||
// attributes as another Float64Callbacks also registered for the same
|
||||
// instrument.
|
||||
//
|
||||
// The function needs to be concurrent safe.
|
||||
type Float64Callback func(context.Context, Float64Observer) error
|
||||
|
||||
// Float64ObservableOption applies options to float64 Observer instruments.
|
||||
type Float64ObservableOption interface {
|
||||
Float64ObservableCounterOption
|
||||
Float64ObservableUpDownCounterOption
|
||||
Float64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type float64CallbackOpt struct {
|
||||
cback Float64Callback
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableCounter(cfg Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableUpDownCounter(cfg Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o float64CallbackOpt) applyFloat64ObservableGauge(cfg Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithFloat64Callback adds callback to be called for an instrument.
|
||||
func WithFloat64Callback(callback Float64Callback) Float64ObservableOption {
|
||||
return float64CallbackOpt{callback}
|
||||
}
|
||||
256
vendor/go.opentelemetry.io/otel/metric/asyncint64.go
generated
vendored
Normal file
256
vendor/go.opentelemetry.io/otel/metric/asyncint64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
// 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/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Int64Observable describes a set of instruments used asynchronously to record
|
||||
// int64 measurements once per collection cycle. Observations of these
|
||||
// instruments are only made within a callback.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases.
|
||||
type Int64Observable interface {
|
||||
Observable
|
||||
|
||||
int64Observable()
|
||||
}
|
||||
|
||||
// Int64ObservableCounter is an instrument used to asynchronously record
|
||||
// increasing int64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument. The value observed is
|
||||
// assumed the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64ObservableCounter interface {
|
||||
embedded.Int64ObservableCounter
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableCounterConfig returns a new [Int64ObservableCounterConfig]
|
||||
// with all opts applied.
|
||||
func NewInt64ObservableCounterConfig(opts ...Int64ObservableCounterOption) Int64ObservableCounterConfig {
|
||||
var config Int64ObservableCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableCounterConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableCounterOption applies options to a
|
||||
// [Int64ObservableCounterConfig]. See [Int64ObservableOption] and [Option] for
|
||||
// other options that can be used as an Int64ObservableCounterOption.
|
||||
type Int64ObservableCounterOption interface {
|
||||
applyInt64ObservableCounter(Int64ObservableCounterConfig) Int64ObservableCounterConfig
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounter is an instrument used to asynchronously record
|
||||
// int64 measurements once per collection cycle. Observations are only made
|
||||
// within a callback for this instrument. The value observed is assumed the to
|
||||
// be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64ObservableUpDownCounter interface {
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableUpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableUpDownCounterConfig returns a new
|
||||
// [Int64ObservableUpDownCounterConfig] with all opts applied.
|
||||
func NewInt64ObservableUpDownCounterConfig(opts ...Int64ObservableUpDownCounterOption) Int64ObservableUpDownCounterConfig {
|
||||
var config Int64ObservableUpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableUpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableUpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableUpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableUpDownCounterConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterOption applies options to a
|
||||
// [Int64ObservableUpDownCounterConfig]. See [Int64ObservableOption] and
|
||||
// [Option] for other options that can be used as an
|
||||
// Int64ObservableUpDownCounterOption.
|
||||
type Int64ObservableUpDownCounterOption interface {
|
||||
applyInt64ObservableUpDownCounter(Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig
|
||||
}
|
||||
|
||||
// Int64ObservableGauge is an instrument used to asynchronously record
|
||||
// instantaneous int64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64ObservableGauge interface {
|
||||
embedded.Int64ObservableGauge
|
||||
|
||||
Int64Observable
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeConfig contains options for asynchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64ObservableGaugeConfig struct {
|
||||
description string
|
||||
unit string
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObservableGaugeConfig returns a new [Int64ObservableGaugeConfig]
|
||||
// with all opts applied.
|
||||
func NewInt64ObservableGaugeConfig(opts ...Int64ObservableGaugeOption) Int64ObservableGaugeConfig {
|
||||
var config Int64ObservableGaugeConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64ObservableGauge(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64ObservableGaugeConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64ObservableGaugeConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the configured callbacks.
|
||||
func (c Int64ObservableGaugeConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeOption applies options to a
|
||||
// [Int64ObservableGaugeConfig]. See [Int64ObservableOption] and [Option] for
|
||||
// other options that can be used as an Int64ObservableGaugeOption.
|
||||
type Int64ObservableGaugeOption interface {
|
||||
applyInt64ObservableGauge(Int64ObservableGaugeConfig) Int64ObservableGaugeConfig
|
||||
}
|
||||
|
||||
// Int64Observer is a recorder of int64 measurements.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64Observer interface {
|
||||
embedded.Int64Observer
|
||||
|
||||
// Observe records the int64 value.
|
||||
Observe(value int64, opts ...ObserveOption)
|
||||
}
|
||||
|
||||
// Int64Callback is a function registered with a Meter that makes observations
|
||||
// for an Int64Observerable instrument it is registered with. Calls to the
|
||||
// Int64Observer record measurement values for the Int64Observable.
|
||||
//
|
||||
// The function needs to complete in a finite amount of time and the deadline
|
||||
// of the passed context is expected to be honored.
|
||||
//
|
||||
// The function needs to make unique observations across all registered
|
||||
// Int64Callbacks. Meaning, it should not report measurements with the same
|
||||
// attributes as another Int64Callbacks also registered for the same
|
||||
// instrument.
|
||||
//
|
||||
// The function needs to be concurrent safe.
|
||||
type Int64Callback func(context.Context, Int64Observer) error
|
||||
|
||||
// Int64ObservableOption applies options to int64 Observer instruments.
|
||||
type Int64ObservableOption interface {
|
||||
Int64ObservableCounterOption
|
||||
Int64ObservableUpDownCounterOption
|
||||
Int64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type int64CallbackOpt struct {
|
||||
cback Int64Callback
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableCounter(cfg Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableUpDownCounter(cfg Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func (o int64CallbackOpt) applyInt64ObservableGauge(cfg Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, o.cback)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// WithInt64Callback adds callback to be called for an instrument.
|
||||
func WithInt64Callback(callback Int64Callback) Int64ObservableOption {
|
||||
return int64CallbackOpt{callback}
|
||||
}
|
||||
25
vendor/go.opentelemetry.io/otel/metric/config.go
generated
vendored
25
vendor/go.opentelemetry.io/otel/metric/config.go
generated
vendored
|
|
@ -14,17 +14,30 @@
|
|||
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
// MeterConfig contains options for Meters.
|
||||
type MeterConfig struct {
|
||||
instrumentationVersion string
|
||||
schemaURL string
|
||||
attrs attribute.Set
|
||||
|
||||
// Ensure forward compatibility by explicitly making this not comparable.
|
||||
noCmp [0]func() //nolint: unused // This is indeed used.
|
||||
}
|
||||
|
||||
// InstrumentationVersion is the version of the library providing instrumentation.
|
||||
// InstrumentationVersion returns the version of the library providing
|
||||
// instrumentation.
|
||||
func (cfg MeterConfig) InstrumentationVersion() string {
|
||||
return cfg.instrumentationVersion
|
||||
}
|
||||
|
||||
// InstrumentationAttributes returns the attributes associated with the library
|
||||
// providing instrumentation.
|
||||
func (cfg MeterConfig) InstrumentationAttributes() attribute.Set {
|
||||
return cfg.attrs
|
||||
}
|
||||
|
||||
// SchemaURL is the schema_url of the library providing instrumentation.
|
||||
func (cfg MeterConfig) SchemaURL() string {
|
||||
return cfg.schemaURL
|
||||
|
|
@ -60,6 +73,16 @@ func WithInstrumentationVersion(version string) MeterOption {
|
|||
})
|
||||
}
|
||||
|
||||
// WithInstrumentationAttributes sets the instrumentation attributes.
|
||||
//
|
||||
// The passed attributes will be de-duplicated.
|
||||
func WithInstrumentationAttributes(attr ...attribute.KeyValue) MeterOption {
|
||||
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
||||
config.attrs = attribute.NewSet(attr...)
|
||||
return config
|
||||
})
|
||||
}
|
||||
|
||||
// WithSchemaURL sets the schema URL.
|
||||
func WithSchemaURL(schemaURL string) MeterOption {
|
||||
return meterOptionFunc(func(config MeterConfig) MeterConfig {
|
||||
|
|
|
|||
124
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
124
vendor/go.opentelemetry.io/otel/metric/doc.go
generated
vendored
|
|
@ -13,11 +13,125 @@
|
|||
// limitations under the License.
|
||||
|
||||
/*
|
||||
Package metric provides an implementation of the metrics part of the
|
||||
OpenTelemetry API.
|
||||
Package metric provides the OpenTelemetry API used to measure metrics about
|
||||
source code operation.
|
||||
|
||||
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.
|
||||
This API is separate from its implementation so the instrumentation built from
|
||||
it is reusable. See [go.opentelemetry.io/otel/sdk/metric] for the official
|
||||
OpenTelemetry implementation of this API.
|
||||
|
||||
All measurements made with this package are made via instruments. These
|
||||
instruments are created by a [Meter] which itself is created by a
|
||||
[MeterProvider]. Applications need to accept a [MeterProvider] implementation
|
||||
as a starting point when instrumenting. This can be done directly, or by using
|
||||
the OpenTelemetry global MeterProvider via [GetMeterProvider]. Using an
|
||||
appropriately named [Meter] from the accepted [MeterProvider], instrumentation
|
||||
can then be built from the [Meter]'s instruments.
|
||||
|
||||
# Instruments
|
||||
|
||||
Each instrument is designed to make measurements of a particular type. Broadly,
|
||||
all instruments fall into two overlapping logical categories: asynchronous or
|
||||
synchronous, and int64 or float64.
|
||||
|
||||
All synchronous instruments ([Int64Counter], [Int64UpDownCounter],
|
||||
[Int64Histogram], [Float64Counter], [Float64UpDownCounter], [Float64Histogram])
|
||||
are used to measure the operation and performance of source code during the
|
||||
source code execution. These instruments only make measurements when the source
|
||||
code they instrument is run.
|
||||
|
||||
All asynchronous instruments ([Int64ObservableCounter],
|
||||
[Int64ObservableUpDownCounter], [Int64ObservableGauge],
|
||||
[Float64ObservableCounter], [Float64ObservableUpDownCounter],
|
||||
[Float64ObservableGauge]) are used to measure metrics outside of the execution
|
||||
of source code. They are said to make "observations" via a callback function
|
||||
called once every measurement collection cycle.
|
||||
|
||||
Each instrument is also grouped by the value type it measures. Either int64 or
|
||||
float64. The value being measured will dictate which instrument in these
|
||||
categories to use.
|
||||
|
||||
Outside of these two broad categories, instruments are described by the
|
||||
function they are designed to serve. All Counters ([Int64Counter],
|
||||
[Float64Counter], [Int64ObservableCounter], [Float64ObservableCounter]) are
|
||||
designed to measure values that never decrease in value, but instead only
|
||||
incrementally increase in value. UpDownCounters ([Int64UpDownCounter],
|
||||
[Float64UpDownCounter], [Int64ObservableUpDownCounter],
|
||||
[Float64ObservableUpDownCounter]) on the other hand, are designed to measure
|
||||
values that can increase and decrease. When more information
|
||||
needs to be conveyed about all the synchronous measurements made during a
|
||||
collection cycle, a Histogram ([Int64Histogram], [Float64Histogram]) should be
|
||||
used. Finally, when just the most recent measurement needs to be conveyed about an
|
||||
asynchronous measurement, a Gauge ([Int64ObservableGauge],
|
||||
[Float64ObservableGauge]) should be used.
|
||||
|
||||
See the [OpenTelemetry documentation] for more information about instruments
|
||||
and their intended use.
|
||||
|
||||
# API Implementations
|
||||
|
||||
This package does not conform to the standard Go versioning policy, all of its
|
||||
interfaces may have methods added to them without a package major version bump.
|
||||
This non-standard API evolution could surprise an uninformed implementation
|
||||
author. They could unknowingly build their implementation in a way that would
|
||||
result in a runtime panic for their users that update to the new API.
|
||||
|
||||
The API is designed to help inform an instrumentation author about this
|
||||
non-standard API evolution. It requires them to choose a default behavior for
|
||||
unimplemented interface methods. There are three behavior choices they can
|
||||
make:
|
||||
|
||||
- Compilation failure
|
||||
- Panic
|
||||
- Default to another implementation
|
||||
|
||||
All interfaces in this API embed a corresponding interface from
|
||||
[go.opentelemetry.io/otel/metric/embedded]. If an author wants the default
|
||||
behavior of their implementations to be a compilation failure, signaling to
|
||||
their users they need to update to the latest version of that implementation,
|
||||
they need to embed the corresponding interface from
|
||||
[go.opentelemetry.io/otel/metric/embedded] in their implementation. For
|
||||
example,
|
||||
|
||||
import "go.opentelemetry.io/otel/metric/embedded"
|
||||
|
||||
type MeterProvider struct {
|
||||
embedded.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
If an author wants the default behavior of their implementations to a panic,
|
||||
they need to embed the API interface directly.
|
||||
|
||||
import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
type MeterProvider struct {
|
||||
metric.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
This is not a recommended behavior as it could lead to publishing packages that
|
||||
contain runtime panics when users update other package that use newer versions
|
||||
of [go.opentelemetry.io/otel/metric].
|
||||
|
||||
Finally, an author can embed another implementation in theirs. The embedded
|
||||
implementation will be used for methods not defined by the author. For example,
|
||||
an author who want to default to silently dropping the call can use
|
||||
[go.opentelemetry.io/otel/metric/noop]:
|
||||
|
||||
import "go.opentelemetry.io/otel/metric/noop"
|
||||
|
||||
type MeterProvider struct {
|
||||
noop.MeterProvider
|
||||
// ...
|
||||
}
|
||||
|
||||
It is strongly recommended that authors only embed
|
||||
[go.opentelemetry.io/otel/metric/noop] if they choose this default behavior.
|
||||
That implementation is the only one OpenTelemetry authors can guarantee will
|
||||
fully implement all the API interfaces when a user updates their API.
|
||||
|
||||
[OpenTelemetry documentation]: https://opentelemetry.io/docs/concepts/signals/metrics/
|
||||
[GetMeterProvider]: https://pkg.go.dev/go.opentelemetry.io/otel#GetMeterProvider
|
||||
*/
|
||||
package metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
|
|
|||
234
vendor/go.opentelemetry.io/otel/metric/embedded/embedded.go
generated
vendored
Normal file
234
vendor/go.opentelemetry.io/otel/metric/embedded/embedded.go
generated
vendored
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
// 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 embedded provides interfaces embedded within the [OpenTelemetry
|
||||
// metric API].
|
||||
//
|
||||
// Implementers of the [OpenTelemetry metric API] can embed the relevant type
|
||||
// from this package into their implementation directly. Doing so will result
|
||||
// in a compilation error for users when the [OpenTelemetry metric API] is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
//
|
||||
// [OpenTelemetry metric API]: https://pkg.go.dev/go.opentelemetry.io/otel/metric
|
||||
package embedded // import "go.opentelemetry.io/otel/metric/embedded"
|
||||
|
||||
// MeterProvider is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.MeterProvider].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.MeterProvider] if you want users to
|
||||
// experience a compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.MeterProvider]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type MeterProvider interface{ meterProvider() }
|
||||
|
||||
// Meter is embedded in [go.opentelemetry.io/otel/metric.Meter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Meter] if you want users to experience a
|
||||
// compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Meter] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Meter interface{ meter() }
|
||||
|
||||
// Float64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Observer interface{ float64Observer() }
|
||||
|
||||
// Int64Observer is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Observer] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Observer interface{ int64Observer() }
|
||||
|
||||
// Observer is embedded in [go.opentelemetry.io/otel/metric.Observer].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Observer] if you want users to experience a
|
||||
// compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Observer]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Observer interface{ observer() }
|
||||
|
||||
// Registration is embedded in [go.opentelemetry.io/otel/metric.Registration].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Registration] if you want users to
|
||||
// experience a compilation error, signaling they need to update to your latest
|
||||
// implementation, when the [go.opentelemetry.io/otel/metric.Registration]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Registration interface{ registration() }
|
||||
|
||||
// Float64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Counter interface{ float64Counter() }
|
||||
|
||||
// Float64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Float64Histogram interface{ float64Histogram() }
|
||||
|
||||
// Float64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableCounter interface{ float64ObservableCounter() }
|
||||
|
||||
// Float64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableGauge]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableGauge interface{ float64ObservableGauge() }
|
||||
|
||||
// Float64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// if you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Float64ObservableUpDownCounter interface{ float64ObservableUpDownCounter() }
|
||||
|
||||
// Float64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Float64UpDownCounter] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Float64UpDownCounter interface{ float64UpDownCounter() }
|
||||
|
||||
// Int64Counter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] if you want users
|
||||
// to experience a compilation error, signaling they need to update to your
|
||||
// latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Counter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Counter interface{ int64Counter() }
|
||||
|
||||
// Int64Histogram is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64Histogram] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64Histogram interface{ int64Histogram() }
|
||||
|
||||
// Int64ObservableCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableCounter interface{ int64ObservableCounter() }
|
||||
|
||||
// Int64ObservableGauge is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] if you
|
||||
// want users to experience a compilation error, signaling they need to update
|
||||
// to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableGauge] interface
|
||||
// is extended (which is something that can happen without a major version bump
|
||||
// of the API package).
|
||||
type Int64ObservableGauge interface{ int64ObservableGauge() }
|
||||
|
||||
// Int64ObservableUpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter] if
|
||||
// you want users to experience a compilation error, signaling they need to
|
||||
// update to your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64ObservableUpDownCounter]
|
||||
// interface is extended (which is something that can happen without a major
|
||||
// version bump of the API package).
|
||||
type Int64ObservableUpDownCounter interface{ int64ObservableUpDownCounter() }
|
||||
|
||||
// Int64UpDownCounter is embedded in
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter].
|
||||
//
|
||||
// Embed this interface in your implementation of the
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] if you want
|
||||
// users to experience a compilation error, signaling they need to update to
|
||||
// your latest implementation, when the
|
||||
// [go.opentelemetry.io/otel/metric.Int64UpDownCounter] interface is
|
||||
// extended (which is something that can happen without a major version bump of
|
||||
// the API package).
|
||||
type Int64UpDownCounter interface{ int64UpDownCounter() }
|
||||
42
vendor/go.opentelemetry.io/otel/metric/global/global.go
generated
vendored
42
vendor/go.opentelemetry.io/otel/metric/global/global.go
generated
vendored
|
|
@ -1,42 +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 global // import "go.opentelemetry.io/otel/metric/global"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/internal/global"
|
||||
)
|
||||
|
||||
// Meter returns a Meter 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 trace provider.
|
||||
// If none is registered then a No-op MeterProvider is returned.
|
||||
func MeterProvider() metric.MeterProvider {
|
||||
return global.MeterProvider()
|
||||
}
|
||||
|
||||
// SetMeterProvider registers `mp` as the global meter provider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
global.SetMeterProvider(mp)
|
||||
}
|
||||
49
vendor/go.opentelemetry.io/otel/metric/global/metric.go
generated
vendored
Normal file
49
vendor/go.opentelemetry.io/otel/metric/global/metric.go
generated
vendored
Normal file
|
|
@ -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/metric/global"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/internal/global"
|
||||
)
|
||||
|
||||
// Meter returns a Meter from the global MeterProvider. The name 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 name is empty, then a implementation defined default name will be
|
||||
// used instead.
|
||||
//
|
||||
// If this is called before a global MeterProvider is registered the returned
|
||||
// Meter will be a No-op implementation of a Meter. When a global MeterProvider
|
||||
// is registered for the first time, the returned Meter, and all the
|
||||
// instruments it has created or will create, are recreated automatically from
|
||||
// the new MeterProvider.
|
||||
//
|
||||
// This is short for GetMeterProvider().Meter(name).
|
||||
func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter {
|
||||
return MeterProvider().Meter(instrumentationName, opts...)
|
||||
}
|
||||
|
||||
// MeterProvider returns the registered global meter provider.
|
||||
//
|
||||
// If no global MeterProvider has been registered, a No-op MeterProvider implementation is returned. When a global MeterProvider is registered for the first time, the returned MeterProvider, and all the Meters it has created or will create, are recreated automatically from the new MeterProvider.
|
||||
func MeterProvider() metric.MeterProvider {
|
||||
return global.MeterProvider()
|
||||
}
|
||||
|
||||
// SetMeterProvider registers mp as the global MeterProvider.
|
||||
func SetMeterProvider(mp metric.MeterProvider) {
|
||||
global.SetMeterProvider(mp)
|
||||
}
|
||||
332
vendor/go.opentelemetry.io/otel/metric/instrument.go
generated
vendored
Normal file
332
vendor/go.opentelemetry.io/otel/metric/instrument.go
generated
vendored
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
// 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/metric"
|
||||
|
||||
import "go.opentelemetry.io/otel/attribute"
|
||||
|
||||
// Observable is used as a grouping mechanism for all instruments that are
|
||||
// updated within a Callback.
|
||||
type Observable interface {
|
||||
observable()
|
||||
}
|
||||
|
||||
// InstrumentOption applies options to all instruments.
|
||||
type InstrumentOption interface {
|
||||
Int64CounterOption
|
||||
Int64UpDownCounterOption
|
||||
Int64HistogramOption
|
||||
Int64ObservableCounterOption
|
||||
Int64ObservableUpDownCounterOption
|
||||
Int64ObservableGaugeOption
|
||||
|
||||
Float64CounterOption
|
||||
Float64UpDownCounterOption
|
||||
Float64HistogramOption
|
||||
Float64ObservableCounterOption
|
||||
Float64ObservableUpDownCounterOption
|
||||
Float64ObservableGaugeOption
|
||||
}
|
||||
|
||||
type descOpt string
|
||||
|
||||
func (o descOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithDescription sets the instrument description.
|
||||
func WithDescription(desc string) InstrumentOption { return descOpt(desc) }
|
||||
|
||||
type unitOpt string
|
||||
|
||||
func (o unitOpt) applyFloat64Counter(c Float64CounterConfig) Float64CounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64UpDownCounter(c Float64UpDownCounterConfig) Float64UpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64Histogram(c Float64HistogramConfig) Float64HistogramConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableCounter(c Float64ObservableCounterConfig) Float64ObservableCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableUpDownCounter(c Float64ObservableUpDownCounterConfig) Float64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64ObservableGauge(c Float64ObservableGaugeConfig) Float64ObservableGaugeConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Counter(c Int64CounterConfig) Int64CounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64UpDownCounter(c Int64UpDownCounterConfig) Int64UpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Histogram(c Int64HistogramConfig) Int64HistogramConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableCounter(c Int64ObservableCounterConfig) Int64ObservableCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableUpDownCounter(c Int64ObservableUpDownCounterConfig) Int64ObservableUpDownCounterConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64ObservableGauge(c Int64ObservableGaugeConfig) Int64ObservableGaugeConfig {
|
||||
c.unit = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithUnit sets the instrument unit.
|
||||
func WithUnit(u string) InstrumentOption { return unitOpt(u) }
|
||||
|
||||
// AddOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a AddOption.
|
||||
type AddOption interface {
|
||||
applyAdd(AddConfig) AddConfig
|
||||
}
|
||||
|
||||
// AddConfig contains options for an addition measurement.
|
||||
type AddConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewAddConfig returns a new [AddConfig] with all opts applied.
|
||||
func NewAddConfig(opts []AddOption) AddConfig {
|
||||
config := AddConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyAdd(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c AddConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// RecordOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a RecordOption.
|
||||
type RecordOption interface {
|
||||
applyRecord(RecordConfig) RecordConfig
|
||||
}
|
||||
|
||||
// RecordConfig contains options for a recorded measurement.
|
||||
type RecordConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewRecordConfig returns a new [RecordConfig] with all opts applied.
|
||||
func NewRecordConfig(opts []RecordOption) RecordConfig {
|
||||
config := RecordConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyRecord(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c RecordConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// ObserveOption applies options to an addition measurement. See
|
||||
// [MeasurementOption] for other options that can be used as a ObserveOption.
|
||||
type ObserveOption interface {
|
||||
applyObserve(ObserveConfig) ObserveConfig
|
||||
}
|
||||
|
||||
// ObserveConfig contains options for an observed measurement.
|
||||
type ObserveConfig struct {
|
||||
attrs attribute.Set
|
||||
}
|
||||
|
||||
// NewObserveConfig returns a new [ObserveConfig] with all opts applied.
|
||||
func NewObserveConfig(opts []ObserveOption) ObserveConfig {
|
||||
config := ObserveConfig{attrs: *attribute.EmptySet()}
|
||||
for _, o := range opts {
|
||||
config = o.applyObserve(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Attributes returns the configured attribute set.
|
||||
func (c ObserveConfig) Attributes() attribute.Set {
|
||||
return c.attrs
|
||||
}
|
||||
|
||||
// MeasurementOption applies options to all instrument measurement.
|
||||
type MeasurementOption interface {
|
||||
AddOption
|
||||
RecordOption
|
||||
ObserveOption
|
||||
}
|
||||
|
||||
type attrOpt struct {
|
||||
set attribute.Set
|
||||
}
|
||||
|
||||
// mergeSets returns the union of keys between a and b. Any duplicate keys will
|
||||
// use the value associated with b.
|
||||
func mergeSets(a, b attribute.Set) attribute.Set {
|
||||
// NewMergeIterator uses the first value for any duplicates.
|
||||
iter := attribute.NewMergeIterator(&b, &a)
|
||||
merged := make([]attribute.KeyValue, 0, a.Len()+b.Len())
|
||||
for iter.Next() {
|
||||
merged = append(merged, iter.Attribute())
|
||||
}
|
||||
return attribute.NewSet(merged...)
|
||||
}
|
||||
|
||||
func (o attrOpt) applyAdd(c AddConfig) AddConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (o attrOpt) applyRecord(c RecordConfig) RecordConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func (o attrOpt) applyObserve(c ObserveConfig) ObserveConfig {
|
||||
switch {
|
||||
case o.set.Len() == 0:
|
||||
case c.attrs.Len() == 0:
|
||||
c.attrs = o.set
|
||||
default:
|
||||
c.attrs = mergeSets(c.attrs, o.set)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
// WithAttributeSet sets the attribute Set associated with a measurement is
|
||||
// made with.
|
||||
//
|
||||
// If multiple WithAttributeSet or WithAttributes options are passed the
|
||||
// attributes will be merged together in the order they are passed. Attributes
|
||||
// with duplicate keys will use the last value passed.
|
||||
func WithAttributeSet(attributes attribute.Set) MeasurementOption {
|
||||
return attrOpt{set: attributes}
|
||||
}
|
||||
|
||||
// WithAttributes converts attributes into an attribute Set and sets the Set to
|
||||
// be associated with a measurement. This is shorthand for:
|
||||
//
|
||||
// cp := make([]attribute.KeyValue, len(attributes))
|
||||
// copy(cp, attributes)
|
||||
// WithAttributes(attribute.NewSet(cp...))
|
||||
//
|
||||
// [attribute.NewSet] may modify the passed attributes so this will make a copy
|
||||
// of attributes before creating a set in order to ensure this function is
|
||||
// concurrent safe. This makes this option function less optimized in
|
||||
// comparison to [WithAttributeSet]. Therefore, [WithAttributeSet] should be
|
||||
// preferred for performance sensitive code.
|
||||
//
|
||||
// See [WithAttributeSet] for information about how multiple WithAttributes are
|
||||
// merged.
|
||||
func WithAttributes(attributes ...attribute.KeyValue) MeasurementOption {
|
||||
cp := make([]attribute.KeyValue, len(attributes))
|
||||
copy(cp, attributes)
|
||||
return attrOpt{set: attribute.NewSet(cp...)}
|
||||
}
|
||||
131
vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go
generated
vendored
131
vendor/go.opentelemetry.io/otel/metric/instrument/asyncfloat64.go
generated
vendored
|
|
@ -1,131 +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 instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
)
|
||||
|
||||
// Float64Observable describes a set of instruments used asynchronously to
|
||||
// record float64 measurements once per collection cycle. Observations of
|
||||
// these instruments are only made within a callback.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64Observable interface {
|
||||
Asynchronous
|
||||
|
||||
float64Observable()
|
||||
}
|
||||
|
||||
// Float64ObservableCounter is an instrument used to asynchronously record
|
||||
// increasing float64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument. The value observed is
|
||||
// assumed the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64ObservableCounter interface{ Float64Observable }
|
||||
|
||||
// Float64ObservableUpDownCounter is an instrument used to asynchronously
|
||||
// record float64 measurements once per collection cycle. Observations are only
|
||||
// made within a callback for this instrument. The value observed is assumed
|
||||
// the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64ObservableUpDownCounter interface{ Float64Observable }
|
||||
|
||||
// Float64ObservableGauge is an instrument used to asynchronously record
|
||||
// instantaneous float64 measurements once per collection cycle. Observations
|
||||
// are only made within a callback for this instrument.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64ObservableGauge interface{ Float64Observable }
|
||||
|
||||
// Float64Observer is a recorder of float64 measurements.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64Observer interface {
|
||||
Observe(value float64, attributes ...attribute.KeyValue)
|
||||
}
|
||||
|
||||
// Float64Callback is a function registered with a Meter that makes
|
||||
// observations for a Float64Observerable instrument it is registered with.
|
||||
// Calls to the Float64Observer record measurement values for the
|
||||
// Float64Observable.
|
||||
//
|
||||
// The function needs to complete in a finite amount of time and the deadline
|
||||
// of the passed context is expected to be honored.
|
||||
//
|
||||
// The function needs to make unique observations across all registered
|
||||
// Float64Callbacks. Meaning, it should not report measurements with the same
|
||||
// attributes as another Float64Callbacks also registered for the same
|
||||
// instrument.
|
||||
//
|
||||
// The function needs to be concurrent safe.
|
||||
type Float64Callback func(context.Context, Float64Observer) error
|
||||
|
||||
// Float64ObserverConfig contains options for Asynchronous instruments that
|
||||
// observe float64 values.
|
||||
type Float64ObserverConfig struct {
|
||||
description string
|
||||
unit unit.Unit
|
||||
callbacks []Float64Callback
|
||||
}
|
||||
|
||||
// NewFloat64ObserverConfig returns a new Float64ObserverConfig with all opts
|
||||
// applied.
|
||||
func NewFloat64ObserverConfig(opts ...Float64ObserverOption) Float64ObserverConfig {
|
||||
var config Float64ObserverConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64Observer(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the Config description.
|
||||
func (c Float64ObserverConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the Config unit.
|
||||
func (c Float64ObserverConfig) Unit() unit.Unit {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the Config callbacks.
|
||||
func (c Float64ObserverConfig) Callbacks() []Float64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Float64ObserverOption applies options to float64 Observer instruments.
|
||||
type Float64ObserverOption interface {
|
||||
applyFloat64Observer(Float64ObserverConfig) Float64ObserverConfig
|
||||
}
|
||||
|
||||
type float64ObserverOptionFunc func(Float64ObserverConfig) Float64ObserverConfig
|
||||
|
||||
func (fn float64ObserverOptionFunc) applyFloat64Observer(cfg Float64ObserverConfig) Float64ObserverConfig {
|
||||
return fn(cfg)
|
||||
}
|
||||
|
||||
// WithFloat64Callback adds callback to be called for an instrument.
|
||||
func WithFloat64Callback(callback Float64Callback) Float64ObserverOption {
|
||||
return float64ObserverOptionFunc(func(cfg Float64ObserverConfig) Float64ObserverConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, callback)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
131
vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go
generated
vendored
131
vendor/go.opentelemetry.io/otel/metric/instrument/asyncint64.go
generated
vendored
|
|
@ -1,131 +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 instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
)
|
||||
|
||||
// Int64Observable describes a set of instruments used asynchronously to record
|
||||
// int64 measurements once per collection cycle. Observations of these
|
||||
// instruments are only made within a callback.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Observable interface {
|
||||
Asynchronous
|
||||
|
||||
int64Observable()
|
||||
}
|
||||
|
||||
// Int64ObservableCounter is an instrument used to asynchronously record
|
||||
// increasing int64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument. The value observed is
|
||||
// assumed the to be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64ObservableCounter interface{ Int64Observable }
|
||||
|
||||
// Int64ObservableUpDownCounter is an instrument used to asynchronously record
|
||||
// int64 measurements once per collection cycle. Observations are only made
|
||||
// within a callback for this instrument. The value observed is assumed the to
|
||||
// be the cumulative sum of the count.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64ObservableUpDownCounter interface{ Int64Observable }
|
||||
|
||||
// Int64ObservableGauge is an instrument used to asynchronously record
|
||||
// instantaneous int64 measurements once per collection cycle. Observations are
|
||||
// only made within a callback for this instrument.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64ObservableGauge interface{ Int64Observable }
|
||||
|
||||
// Int64Observer is a recorder of int64 measurements.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Observer interface {
|
||||
Observe(value int64, attributes ...attribute.KeyValue)
|
||||
}
|
||||
|
||||
// Int64Callback is a function registered with a Meter that makes
|
||||
// observations for a Int64Observerable instrument it is registered with.
|
||||
// Calls to the Int64Observer record measurement values for the
|
||||
// Int64Observable.
|
||||
//
|
||||
// The function needs to complete in a finite amount of time and the deadline
|
||||
// of the passed context is expected to be honored.
|
||||
//
|
||||
// The function needs to make unique observations across all registered
|
||||
// Int64Callback. Meaning, it should not report measurements with the same
|
||||
// attributes as another Int64Callbacks also registered for the same
|
||||
// instrument.
|
||||
//
|
||||
// The function needs to be concurrent safe.
|
||||
type Int64Callback func(context.Context, Int64Observer) error
|
||||
|
||||
// Int64ObserverConfig contains options for Asynchronous instruments that
|
||||
// observe int64 values.
|
||||
type Int64ObserverConfig struct {
|
||||
description string
|
||||
unit unit.Unit
|
||||
callbacks []Int64Callback
|
||||
}
|
||||
|
||||
// NewInt64ObserverConfig returns a new Int64ObserverConfig with all opts
|
||||
// applied.
|
||||
func NewInt64ObserverConfig(opts ...Int64ObserverOption) Int64ObserverConfig {
|
||||
var config Int64ObserverConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64Observer(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the Config description.
|
||||
func (c Int64ObserverConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the Config unit.
|
||||
func (c Int64ObserverConfig) Unit() unit.Unit {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Callbacks returns the Config callbacks.
|
||||
func (c Int64ObserverConfig) Callbacks() []Int64Callback {
|
||||
return c.callbacks
|
||||
}
|
||||
|
||||
// Int64ObserverOption applies options to int64 Observer instruments.
|
||||
type Int64ObserverOption interface {
|
||||
applyInt64Observer(Int64ObserverConfig) Int64ObserverConfig
|
||||
}
|
||||
|
||||
type int64ObserverOptionFunc func(Int64ObserverConfig) Int64ObserverConfig
|
||||
|
||||
func (fn int64ObserverOptionFunc) applyInt64Observer(cfg Int64ObserverConfig) Int64ObserverConfig {
|
||||
return fn(cfg)
|
||||
}
|
||||
|
||||
// WithInt64Callback adds callback to be called for an instrument.
|
||||
func WithInt64Callback(callback Int64Callback) Int64ObserverOption {
|
||||
return int64ObserverOptionFunc(func(cfg Int64ObserverConfig) Int64ObserverConfig {
|
||||
cfg.callbacks = append(cfg.callbacks, callback)
|
||||
return cfg
|
||||
})
|
||||
}
|
||||
452
vendor/go.opentelemetry.io/otel/metric/instrument/deprecation.go
generated
vendored
Normal file
452
vendor/go.opentelemetry.io/otel/metric/instrument/deprecation.go
generated
vendored
Normal file
|
|
@ -0,0 +1,452 @@
|
|||
// 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 instrument provides the OpenTelemetry API instruments used to make
|
||||
// measurements.
|
||||
//
|
||||
// Deprecated: Use go.opentelemetry.io/otel/metric instead.
|
||||
package instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
)
|
||||
|
||||
// Float64Observable is an alias for [metric.Float64Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Observable] instead.
|
||||
type Float64Observable metric.Float64Observable
|
||||
|
||||
// Float64ObservableCounter is an alias for [metric.Float64ObservableCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounter] instead.
|
||||
type Float64ObservableCounter metric.Float64ObservableCounter
|
||||
|
||||
// Float64ObservableCounterConfig is an alias for
|
||||
// [metric.Float64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounterConfig] instead.
|
||||
type Float64ObservableCounterConfig metric.Float64ObservableCounterConfig
|
||||
|
||||
// NewFloat64ObservableCounterConfig wraps
|
||||
// [metric.NewFloat64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableCounterConfig] instead.
|
||||
func NewFloat64ObservableCounterConfig(opts ...Float64ObservableCounterOption) Float64ObservableCounterConfig {
|
||||
o := make([]metric.Float64ObservableCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableCounterConfig(o...)
|
||||
return Float64ObservableCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableCounterOption is an alias for
|
||||
// [metric.Float64ObservableCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableCounterOption] instead.
|
||||
type Float64ObservableCounterOption metric.Float64ObservableCounterOption
|
||||
|
||||
// Float64ObservableUpDownCounter is an alias for
|
||||
// [metric.Float64ObservableUpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounter] instead.
|
||||
type Float64ObservableUpDownCounter metric.Float64ObservableUpDownCounter
|
||||
|
||||
// Float64ObservableUpDownCounterConfig is an alias for
|
||||
// [metric.Float64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounterConfig] instead.
|
||||
type Float64ObservableUpDownCounterConfig metric.Float64ObservableUpDownCounterConfig
|
||||
|
||||
// NewFloat64ObservableUpDownCounterConfig wraps
|
||||
// [metric.NewFloat64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableUpDownCounterConfig] instead.
|
||||
func NewFloat64ObservableUpDownCounterConfig(opts ...Float64ObservableUpDownCounterOption) Float64ObservableUpDownCounterConfig {
|
||||
o := make([]metric.Float64ObservableUpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableUpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableUpDownCounterConfig(o...)
|
||||
return Float64ObservableUpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableUpDownCounterOption is an alias for
|
||||
// [metric.Float64ObservableUpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableUpDownCounterOption] instead.
|
||||
type Float64ObservableUpDownCounterOption metric.Float64ObservableUpDownCounterOption
|
||||
|
||||
// Float64ObservableGauge is an alias for [metric.Float64ObservableGauge].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGauge] instead.
|
||||
type Float64ObservableGauge metric.Float64ObservableGauge
|
||||
|
||||
// Float64ObservableGaugeConfig is an alias for
|
||||
// [metric.Float64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGaugeConfig] instead.
|
||||
type Float64ObservableGaugeConfig metric.Float64ObservableGaugeConfig
|
||||
|
||||
// NewFloat64ObservableGaugeConfig wraps
|
||||
// [metric.NewFloat64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64ObservableGaugeConfig] instead.
|
||||
func NewFloat64ObservableGaugeConfig(opts ...Float64ObservableGaugeOption) Float64ObservableGaugeConfig {
|
||||
o := make([]metric.Float64ObservableGaugeOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64ObservableGaugeOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64ObservableGaugeConfig(o...)
|
||||
return Float64ObservableGaugeConfig(c)
|
||||
}
|
||||
|
||||
// Float64ObservableGaugeOption is an alias for
|
||||
// [metric.Float64ObservableGaugeOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableGaugeOption] instead.
|
||||
type Float64ObservableGaugeOption metric.Float64ObservableGaugeOption
|
||||
|
||||
// Float64Observer is an alias for [metric.Float64Observer].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Observer] instead.
|
||||
type Float64Observer metric.Float64Observer
|
||||
|
||||
// Float64Callback is an alias for [metric.Float64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Callback] instead.
|
||||
type Float64Callback metric.Float64Callback
|
||||
|
||||
// Float64ObservableOption is an alias for [metric.Float64ObservableOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64ObservableOption] instead.
|
||||
type Float64ObservableOption metric.Float64ObservableOption
|
||||
|
||||
// WithFloat64Callback wraps [metric.WithFloat64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.WithFloat64Callback] instead.
|
||||
func WithFloat64Callback(callback Float64Callback) Float64ObservableOption {
|
||||
cback := metric.Float64Callback(callback)
|
||||
opt := metric.WithFloat64Callback(cback)
|
||||
return Float64ObservableOption(opt)
|
||||
}
|
||||
|
||||
// Int64Observable is an alias for [metric.Int64Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Observable] instead.
|
||||
type Int64Observable metric.Int64Observable
|
||||
|
||||
// Int64ObservableCounter is an alias for [metric.Int64ObservableCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounter] instead.
|
||||
type Int64ObservableCounter metric.Int64ObservableCounter
|
||||
|
||||
// Int64ObservableCounterConfig is an alias for
|
||||
// [metric.Int64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounterConfig] instead.
|
||||
type Int64ObservableCounterConfig metric.Int64ObservableCounterConfig
|
||||
|
||||
// NewInt64ObservableCounterConfig wraps
|
||||
// [metric.NewInt64ObservableCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableCounterConfig] instead.
|
||||
func NewInt64ObservableCounterConfig(opts ...Int64ObservableCounterOption) Int64ObservableCounterConfig {
|
||||
o := make([]metric.Int64ObservableCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableCounterConfig(o...)
|
||||
return Int64ObservableCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableCounterOption is an alias for
|
||||
// [metric.Int64ObservableCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableCounterOption] instead.
|
||||
type Int64ObservableCounterOption metric.Int64ObservableCounterOption
|
||||
|
||||
// Int64ObservableUpDownCounter is an alias for
|
||||
// [metric.Int64ObservableUpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounter] instead.
|
||||
type Int64ObservableUpDownCounter metric.Int64ObservableUpDownCounter
|
||||
|
||||
// Int64ObservableUpDownCounterConfig is an alias for
|
||||
// [metric.Int64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounterConfig] instead.
|
||||
type Int64ObservableUpDownCounterConfig metric.Int64ObservableUpDownCounterConfig
|
||||
|
||||
// NewInt64ObservableUpDownCounterConfig wraps
|
||||
// [metric.NewInt64ObservableUpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableUpDownCounterConfig] instead.
|
||||
func NewInt64ObservableUpDownCounterConfig(opts ...Int64ObservableUpDownCounterOption) Int64ObservableUpDownCounterConfig {
|
||||
o := make([]metric.Int64ObservableUpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableUpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableUpDownCounterConfig(o...)
|
||||
return Int64ObservableUpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableUpDownCounterOption is an alias for
|
||||
// [metric.Int64ObservableUpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableUpDownCounterOption] instead.
|
||||
type Int64ObservableUpDownCounterOption metric.Int64ObservableUpDownCounterOption
|
||||
|
||||
// Int64ObservableGauge is an alias for [metric.Int64ObservableGauge].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGauge] instead.
|
||||
type Int64ObservableGauge metric.Int64ObservableGauge
|
||||
|
||||
// Int64ObservableGaugeConfig is an alias for
|
||||
// [metric.Int64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGaugeConfig] instead.
|
||||
type Int64ObservableGaugeConfig metric.Int64ObservableGaugeConfig
|
||||
|
||||
// NewInt64ObservableGaugeConfig wraps [metric.NewInt64ObservableGaugeConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64ObservableGaugeConfig] instead.
|
||||
func NewInt64ObservableGaugeConfig(opts ...Int64ObservableGaugeOption) Int64ObservableGaugeConfig {
|
||||
o := make([]metric.Int64ObservableGaugeOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64ObservableGaugeOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64ObservableGaugeConfig(o...)
|
||||
return Int64ObservableGaugeConfig(c)
|
||||
}
|
||||
|
||||
// Int64ObservableGaugeOption is an alias for
|
||||
// [metric.Int64ObservableGaugeOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableGaugeOption] instead.
|
||||
type Int64ObservableGaugeOption metric.Int64ObservableGaugeOption
|
||||
|
||||
// Int64Observer is an alias for [metric.Int64Observer].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Observer] instead.
|
||||
type Int64Observer metric.Int64Observer
|
||||
|
||||
// Int64Callback is an alias for [metric.Int64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Callback] instead.
|
||||
type Int64Callback metric.Int64Callback
|
||||
|
||||
// Int64ObservableOption is an alias for [metric.Int64ObservableOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64ObservableOption] instead.
|
||||
type Int64ObservableOption metric.Int64ObservableOption
|
||||
|
||||
// WithInt64Callback wraps [metric.WithInt64Callback].
|
||||
//
|
||||
// Deprecated: Use [metric.WithInt64Callback] instead.
|
||||
func WithInt64Callback(callback Int64Callback) Int64ObservableOption {
|
||||
cback := metric.Int64Callback(callback)
|
||||
opt := metric.WithInt64Callback(cback)
|
||||
return Int64ObservableOption(opt)
|
||||
}
|
||||
|
||||
// Float64Counter is an alias for [metric.Float64Counter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Counter] instead.
|
||||
type Float64Counter metric.Float64Counter
|
||||
|
||||
// Float64CounterConfig is an alias for [metric.Float64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64CounterConfig] instead.
|
||||
type Float64CounterConfig metric.Float64CounterConfig
|
||||
|
||||
// NewFloat64CounterConfig wraps [metric.NewFloat64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64CounterConfig] instead.
|
||||
func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
|
||||
o := make([]metric.Float64CounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64CounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64CounterConfig(o...)
|
||||
return Float64CounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64CounterOption is an alias for [metric.Float64CounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64CounterOption] instead.
|
||||
type Float64CounterOption metric.Float64CounterOption
|
||||
|
||||
// Float64UpDownCounter is an alias for [metric.Float64UpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounter] instead.
|
||||
type Float64UpDownCounter metric.Float64UpDownCounter
|
||||
|
||||
// Float64UpDownCounterConfig is an alias for
|
||||
// [metric.Float64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounterConfig] instead.
|
||||
type Float64UpDownCounterConfig metric.Float64UpDownCounterConfig
|
||||
|
||||
// NewFloat64UpDownCounterConfig wraps [metric.NewFloat64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64UpDownCounterConfig] instead.
|
||||
func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
|
||||
o := make([]metric.Float64UpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64UpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64UpDownCounterConfig(o...)
|
||||
return Float64UpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Float64UpDownCounterOption is an alias for
|
||||
// [metric.Float64UpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64UpDownCounterOption] instead.
|
||||
type Float64UpDownCounterOption metric.Float64UpDownCounterOption
|
||||
|
||||
// Float64Histogram is an alias for [metric.Float64Histogram].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64Histogram] instead.
|
||||
type Float64Histogram metric.Float64Histogram
|
||||
|
||||
// Float64HistogramConfig is an alias for [metric.Float64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64HistogramConfig] instead.
|
||||
type Float64HistogramConfig metric.Float64HistogramConfig
|
||||
|
||||
// NewFloat64HistogramConfig wraps [metric.NewFloat64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewFloat64HistogramConfig] instead.
|
||||
func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
|
||||
o := make([]metric.Float64HistogramOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Float64HistogramOption(opts[i])
|
||||
}
|
||||
c := metric.NewFloat64HistogramConfig(o...)
|
||||
return Float64HistogramConfig(c)
|
||||
}
|
||||
|
||||
// Float64HistogramOption is an alias for [metric.Float64HistogramOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Float64HistogramOption] instead.
|
||||
type Float64HistogramOption metric.Float64HistogramOption
|
||||
|
||||
// Int64Counter is an alias for [metric.Int64Counter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Counter] instead.
|
||||
type Int64Counter metric.Int64Counter
|
||||
|
||||
// Int64CounterConfig is an alias for [metric.Int64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64CounterConfig] instead.
|
||||
type Int64CounterConfig metric.Int64CounterConfig
|
||||
|
||||
// NewInt64CounterConfig wraps [metric.NewInt64CounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64CounterConfig] instead.
|
||||
func NewInt64CounterConfig(opts ...Int64CounterOption) Int64CounterConfig {
|
||||
o := make([]metric.Int64CounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64CounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64CounterConfig(o...)
|
||||
return Int64CounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64CounterOption is an alias for [metric.Int64CounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64CounterOption] instead.
|
||||
type Int64CounterOption metric.Int64CounterOption
|
||||
|
||||
// Int64UpDownCounter is an alias for [metric.Int64UpDownCounter].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounter] instead.
|
||||
type Int64UpDownCounter metric.Int64UpDownCounter
|
||||
|
||||
// Int64UpDownCounterConfig is an alias for [metric.Int64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounterConfig] instead.
|
||||
type Int64UpDownCounterConfig metric.Int64UpDownCounterConfig
|
||||
|
||||
// NewInt64UpDownCounterConfig wraps [metric.NewInt64UpDownCounterConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64UpDownCounterConfig] instead.
|
||||
func NewInt64UpDownCounterConfig(opts ...Int64UpDownCounterOption) Int64UpDownCounterConfig {
|
||||
o := make([]metric.Int64UpDownCounterOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64UpDownCounterOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64UpDownCounterConfig(o...)
|
||||
return Int64UpDownCounterConfig(c)
|
||||
}
|
||||
|
||||
// Int64UpDownCounterOption is an alias for [metric.Int64UpDownCounterOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64UpDownCounterOption] instead.
|
||||
type Int64UpDownCounterOption metric.Int64UpDownCounterOption
|
||||
|
||||
// Int64Histogram is an alias for [metric.Int64Histogram].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64Histogram] instead.
|
||||
type Int64Histogram metric.Int64Histogram
|
||||
|
||||
// Int64HistogramConfig is an alias for [metric.Int64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64HistogramConfig] instead.
|
||||
type Int64HistogramConfig metric.Int64HistogramConfig
|
||||
|
||||
// NewInt64HistogramConfig wraps [metric.NewInt64HistogramConfig].
|
||||
//
|
||||
// Deprecated: Use [metric.NewInt64HistogramConfig] instead.
|
||||
func NewInt64HistogramConfig(opts ...Int64HistogramOption) Int64HistogramConfig {
|
||||
o := make([]metric.Int64HistogramOption, len(opts))
|
||||
for i := range opts {
|
||||
o[i] = metric.Int64HistogramOption(opts[i])
|
||||
}
|
||||
c := metric.NewInt64HistogramConfig(o...)
|
||||
return Int64HistogramConfig(c)
|
||||
}
|
||||
|
||||
// Int64HistogramOption is an alias for [metric.Int64HistogramOption].
|
||||
//
|
||||
// Deprecated: Use [metric.Int64HistogramOption] instead.
|
||||
type Int64HistogramOption metric.Int64HistogramOption
|
||||
|
||||
// Observable is an alias for [metric.Observable].
|
||||
//
|
||||
// Deprecated: Use [metric.Observable] instead.
|
||||
type Observable metric.Observable
|
||||
|
||||
// Option is an alias for [metric.InstrumentOption].
|
||||
//
|
||||
// Deprecated: Use [metric.InstrumentOption] instead.
|
||||
type Option metric.InstrumentOption
|
||||
|
||||
// WithDescription is an alias for [metric.WithDescription].
|
||||
//
|
||||
// Deprecated: Use [metric.WithDescription] instead.
|
||||
func WithDescription(desc string) Option {
|
||||
o := metric.WithDescription(desc)
|
||||
return Option(o)
|
||||
}
|
||||
|
||||
// WithUnit is an alias for [metric.WithUnit].
|
||||
//
|
||||
// Deprecated: Use [metric.WithUnit] instead.
|
||||
func WithUnit(u string) Option {
|
||||
o := metric.WithUnit(u)
|
||||
return Option(o)
|
||||
}
|
||||
90
vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go
generated
vendored
90
vendor/go.opentelemetry.io/otel/metric/instrument/instrument.go
generated
vendored
|
|
@ -1,90 +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 instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import "go.opentelemetry.io/otel/metric/unit"
|
||||
|
||||
// Asynchronous instruments are instruments that are updated within a Callback.
|
||||
// If an instrument is observed outside of it's callback it should be an error.
|
||||
//
|
||||
// This interface is used as a grouping mechanism.
|
||||
type Asynchronous interface {
|
||||
asynchronous()
|
||||
}
|
||||
|
||||
// Synchronous instruments are updated in line with application code.
|
||||
//
|
||||
// This interface is used as a grouping mechanism.
|
||||
type Synchronous interface {
|
||||
synchronous()
|
||||
}
|
||||
|
||||
// Option applies options to all instruments.
|
||||
type Option interface {
|
||||
Float64ObserverOption
|
||||
Int64ObserverOption
|
||||
Float64Option
|
||||
Int64Option
|
||||
}
|
||||
|
||||
type descOpt string
|
||||
|
||||
func (o descOpt) applyFloat64(c Float64Config) Float64Config {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64(c Int64Config) Int64Config {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyFloat64Observer(c Float64ObserverConfig) Float64ObserverConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o descOpt) applyInt64Observer(c Int64ObserverConfig) Int64ObserverConfig {
|
||||
c.description = string(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithDescription sets the instrument description.
|
||||
func WithDescription(desc string) Option { return descOpt(desc) }
|
||||
|
||||
type unitOpt unit.Unit
|
||||
|
||||
func (o unitOpt) applyFloat64(c Float64Config) Float64Config {
|
||||
c.unit = unit.Unit(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64(c Int64Config) Int64Config {
|
||||
c.unit = unit.Unit(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyFloat64Observer(c Float64ObserverConfig) Float64ObserverConfig {
|
||||
c.unit = unit.Unit(o)
|
||||
return c
|
||||
}
|
||||
|
||||
func (o unitOpt) applyInt64Observer(c Int64ObserverConfig) Int64ObserverConfig {
|
||||
c.unit = unit.Unit(o)
|
||||
return c
|
||||
}
|
||||
|
||||
// WithUnit sets the instrument unit.
|
||||
func WithUnit(u unit.Unit) Option { return unitOpt(u) }
|
||||
86
vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go
generated
vendored
86
vendor/go.opentelemetry.io/otel/metric/instrument/syncfloat64.go
generated
vendored
|
|
@ -1,86 +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 instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
)
|
||||
|
||||
// Float64Counter is an instrument that records increasing float64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64Counter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Float64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// float64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64UpDownCounter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Float64Histogram is an instrument that records a distribution of float64
|
||||
// values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Float64Histogram interface {
|
||||
// Record adds an additional value to the distribution.
|
||||
Record(ctx context.Context, incr float64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Float64Config contains options for Asynchronous instruments that
|
||||
// observe float64 values.
|
||||
type Float64Config struct {
|
||||
description string
|
||||
unit unit.Unit
|
||||
}
|
||||
|
||||
// Float64Config contains options for Synchronous instruments that record
|
||||
// float64 values.
|
||||
func NewFloat64Config(opts ...Float64Option) Float64Config {
|
||||
var config Float64Config
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the Config description.
|
||||
func (c Float64Config) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the Config unit.
|
||||
func (c Float64Config) Unit() unit.Unit {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64Option applies options to synchronous float64 instruments.
|
||||
type Float64Option interface {
|
||||
applyFloat64(Float64Config) Float64Config
|
||||
}
|
||||
86
vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go
generated
vendored
86
vendor/go.opentelemetry.io/otel/metric/instrument/syncint64.go
generated
vendored
|
|
@ -1,86 +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 instrument // import "go.opentelemetry.io/otel/metric/instrument"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/unit"
|
||||
)
|
||||
|
||||
// Int64Counter is an instrument that records increasing int64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Counter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// int64 values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64UpDownCounter interface {
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64Histogram is an instrument that records a distribution of int64
|
||||
// values.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
type Int64Histogram interface {
|
||||
// Record adds an additional value to the distribution.
|
||||
Record(ctx context.Context, incr int64, attrs ...attribute.KeyValue)
|
||||
|
||||
Synchronous
|
||||
}
|
||||
|
||||
// Int64Config contains options for Synchronous instruments that record int64
|
||||
// values.
|
||||
type Int64Config struct {
|
||||
description string
|
||||
unit unit.Unit
|
||||
}
|
||||
|
||||
// NewInt64Config returns a new Int64Config with all opts
|
||||
// applied.
|
||||
func NewInt64Config(opts ...Int64Option) Int64Config {
|
||||
var config Int64Config
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the Config description.
|
||||
func (c Int64Config) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the Config unit.
|
||||
func (c Int64Config) Unit() unit.Unit {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64Option applies options to synchronous int64 instruments.
|
||||
type Int64Option interface {
|
||||
applyInt64(Int64Config) Int64Config
|
||||
}
|
||||
167
vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go
generated
vendored
167
vendor/go.opentelemetry.io/otel/metric/internal/global/instruments.go
generated
vendored
|
|
@ -19,27 +19,27 @@ import (
|
|||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// unwrapper unwraps to return the underlying instrument implementation.
|
||||
type unwrapper interface {
|
||||
Unwrap() instrument.Asynchronous
|
||||
Unwrap() metric.Observable
|
||||
}
|
||||
|
||||
type afCounter struct {
|
||||
instrument.Float64Observable
|
||||
embedded.Float64ObservableCounter
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObserverOption
|
||||
opts []metric.Float64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableCounter
|
||||
delegate atomic.Value //metric.Float64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afCounter)(nil)
|
||||
var _ instrument.Float64ObservableCounter = (*afCounter)(nil)
|
||||
var _ metric.Float64ObservableCounter = (*afCounter)(nil)
|
||||
|
||||
func (i *afCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableCounter(i.name, i.opts...)
|
||||
|
|
@ -50,24 +50,25 @@ func (i *afCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afCounter) Unwrap() instrument.Asynchronous {
|
||||
func (i *afCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableCounter)
|
||||
return ctr.(metric.Float64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afUpDownCounter struct {
|
||||
instrument.Float64Observable
|
||||
embedded.Float64ObservableUpDownCounter
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObserverOption
|
||||
opts []metric.Float64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableUpDownCounter
|
||||
delegate atomic.Value //metric.Float64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afUpDownCounter)(nil)
|
||||
var _ instrument.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
var _ metric.Float64ObservableUpDownCounter = (*afUpDownCounter)(nil)
|
||||
|
||||
func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableUpDownCounter(i.name, i.opts...)
|
||||
|
|
@ -78,24 +79,25 @@ func (i *afUpDownCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afUpDownCounter) Unwrap() instrument.Asynchronous {
|
||||
func (i *afUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableUpDownCounter)
|
||||
return ctr.(metric.Float64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type afGauge struct {
|
||||
instrument.Float64Observable
|
||||
embedded.Float64ObservableGauge
|
||||
metric.Float64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Float64ObserverOption
|
||||
opts []metric.Float64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64ObservableGauge
|
||||
delegate atomic.Value //metric.Float64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*afGauge)(nil)
|
||||
var _ instrument.Float64ObservableGauge = (*afGauge)(nil)
|
||||
var _ metric.Float64ObservableGauge = (*afGauge)(nil)
|
||||
|
||||
func (i *afGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64ObservableGauge(i.name, i.opts...)
|
||||
|
|
@ -106,24 +108,25 @@ func (i *afGauge) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *afGauge) Unwrap() instrument.Asynchronous {
|
||||
func (i *afGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Float64ObservableGauge)
|
||||
return ctr.(metric.Float64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiCounter struct {
|
||||
instrument.Int64Observable
|
||||
embedded.Int64ObservableCounter
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
opts []metric.Int64ObservableCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableCounter
|
||||
delegate atomic.Value //metric.Int64ObservableCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiCounter)(nil)
|
||||
var _ instrument.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
var _ metric.Int64ObservableCounter = (*aiCounter)(nil)
|
||||
|
||||
func (i *aiCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableCounter(i.name, i.opts...)
|
||||
|
|
@ -134,24 +137,25 @@ func (i *aiCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiCounter) Unwrap() instrument.Asynchronous {
|
||||
func (i *aiCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableCounter)
|
||||
return ctr.(metric.Int64ObservableCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiUpDownCounter struct {
|
||||
instrument.Int64Observable
|
||||
embedded.Int64ObservableUpDownCounter
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
opts []metric.Int64ObservableUpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableUpDownCounter
|
||||
delegate atomic.Value //metric.Int64ObservableUpDownCounter
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiUpDownCounter)(nil)
|
||||
var _ instrument.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
var _ metric.Int64ObservableUpDownCounter = (*aiUpDownCounter)(nil)
|
||||
|
||||
func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableUpDownCounter(i.name, i.opts...)
|
||||
|
|
@ -162,24 +166,25 @@ func (i *aiUpDownCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiUpDownCounter) Unwrap() instrument.Asynchronous {
|
||||
func (i *aiUpDownCounter) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableUpDownCounter)
|
||||
return ctr.(metric.Int64ObservableUpDownCounter)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type aiGauge struct {
|
||||
instrument.Int64Observable
|
||||
embedded.Int64ObservableGauge
|
||||
metric.Int64Observable
|
||||
|
||||
name string
|
||||
opts []instrument.Int64ObserverOption
|
||||
opts []metric.Int64ObservableGaugeOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64ObservableGauge
|
||||
delegate atomic.Value //metric.Int64ObservableGauge
|
||||
}
|
||||
|
||||
var _ unwrapper = (*aiGauge)(nil)
|
||||
var _ instrument.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
var _ metric.Int64ObservableGauge = (*aiGauge)(nil)
|
||||
|
||||
func (i *aiGauge) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64ObservableGauge(i.name, i.opts...)
|
||||
|
|
@ -190,24 +195,24 @@ func (i *aiGauge) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *aiGauge) Unwrap() instrument.Asynchronous {
|
||||
func (i *aiGauge) Unwrap() metric.Observable {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
return ctr.(instrument.Int64ObservableGauge)
|
||||
return ctr.(metric.Int64ObservableGauge)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Sync Instruments.
|
||||
type sfCounter struct {
|
||||
embedded.Float64Counter
|
||||
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
opts []metric.Float64CounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64Counter
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Float64Counter
|
||||
}
|
||||
|
||||
var _ instrument.Float64Counter = (*sfCounter)(nil)
|
||||
var _ metric.Float64Counter = (*sfCounter)(nil)
|
||||
|
||||
func (i *sfCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Counter(i.name, i.opts...)
|
||||
|
|
@ -218,22 +223,22 @@ func (i *sfCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
|
||||
func (i *sfCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Counter).Add(ctx, incr, attrs...)
|
||||
ctr.(metric.Float64Counter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfUpDownCounter struct {
|
||||
embedded.Float64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
opts []metric.Float64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64UpDownCounter
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Float64UpDownCounter
|
||||
}
|
||||
|
||||
var _ instrument.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
var _ metric.Float64UpDownCounter = (*sfUpDownCounter)(nil)
|
||||
|
||||
func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64UpDownCounter(i.name, i.opts...)
|
||||
|
|
@ -244,22 +249,22 @@ func (i *sfUpDownCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, attrs ...attribute.KeyValue) {
|
||||
func (i *sfUpDownCounter) Add(ctx context.Context, incr float64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64UpDownCounter).Add(ctx, incr, attrs...)
|
||||
ctr.(metric.Float64UpDownCounter).Add(ctx, incr, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type sfHistogram struct {
|
||||
embedded.Float64Histogram
|
||||
|
||||
name string
|
||||
opts []instrument.Float64Option
|
||||
opts []metric.Float64HistogramOption
|
||||
|
||||
delegate atomic.Value //instrument.Float64Histogram
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Float64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Float64Histogram = (*sfHistogram)(nil)
|
||||
var _ metric.Float64Histogram = (*sfHistogram)(nil)
|
||||
|
||||
func (i *sfHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Float64Histogram(i.name, i.opts...)
|
||||
|
|
@ -270,22 +275,22 @@ func (i *sfHistogram) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, attrs ...attribute.KeyValue) {
|
||||
func (i *sfHistogram) Record(ctx context.Context, x float64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Float64Histogram).Record(ctx, x, attrs...)
|
||||
ctr.(metric.Float64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siCounter struct {
|
||||
embedded.Int64Counter
|
||||
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
opts []metric.Int64CounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64Counter
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Int64Counter
|
||||
}
|
||||
|
||||
var _ instrument.Int64Counter = (*siCounter)(nil)
|
||||
var _ metric.Int64Counter = (*siCounter)(nil)
|
||||
|
||||
func (i *siCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Counter(i.name, i.opts...)
|
||||
|
|
@ -296,22 +301,22 @@ func (i *siCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
func (i *siCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Counter).Add(ctx, x, attrs...)
|
||||
ctr.(metric.Int64Counter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siUpDownCounter struct {
|
||||
embedded.Int64UpDownCounter
|
||||
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
opts []metric.Int64UpDownCounterOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64UpDownCounter
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Int64UpDownCounter
|
||||
}
|
||||
|
||||
var _ instrument.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
var _ metric.Int64UpDownCounter = (*siUpDownCounter)(nil)
|
||||
|
||||
func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64UpDownCounter(i.name, i.opts...)
|
||||
|
|
@ -322,22 +327,22 @@ func (i *siUpDownCounter) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
func (i *siUpDownCounter) Add(ctx context.Context, x int64, opts ...metric.AddOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64UpDownCounter).Add(ctx, x, attrs...)
|
||||
ctr.(metric.Int64UpDownCounter).Add(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
type siHistogram struct {
|
||||
embedded.Int64Histogram
|
||||
|
||||
name string
|
||||
opts []instrument.Int64Option
|
||||
opts []metric.Int64HistogramOption
|
||||
|
||||
delegate atomic.Value //instrument.Int64Histogram
|
||||
|
||||
instrument.Synchronous
|
||||
delegate atomic.Value //metric.Int64Histogram
|
||||
}
|
||||
|
||||
var _ instrument.Int64Histogram = (*siHistogram)(nil)
|
||||
var _ metric.Int64Histogram = (*siHistogram)(nil)
|
||||
|
||||
func (i *siHistogram) setDelegate(m metric.Meter) {
|
||||
ctr, err := m.Int64Histogram(i.name, i.opts...)
|
||||
|
|
@ -348,8 +353,8 @@ func (i *siHistogram) setDelegate(m metric.Meter) {
|
|||
i.delegate.Store(ctr)
|
||||
}
|
||||
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, attrs ...attribute.KeyValue) {
|
||||
func (i *siHistogram) Record(ctx context.Context, x int64, opts ...metric.RecordOption) {
|
||||
if ctr := i.delegate.Load(); ctr != nil {
|
||||
ctr.(instrument.Int64Histogram).Record(ctx, x, attrs...)
|
||||
ctr.(metric.Int64Histogram).Record(ctx, x, opts...)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go
generated
vendored
42
vendor/go.opentelemetry.io/otel/metric/internal/global/meter.go
generated
vendored
|
|
@ -21,7 +21,7 @@ import (
|
|||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/metric"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// meterProvider is a placeholder for a configured SDK MeterProvider.
|
||||
|
|
@ -29,6 +29,8 @@ import (
|
|||
// All MeterProvider functionality is forwarded to a delegate once
|
||||
// configured.
|
||||
type meterProvider struct {
|
||||
embedded.MeterProvider
|
||||
|
||||
mtx sync.Mutex
|
||||
meters map[il]*meter
|
||||
|
||||
|
|
@ -100,6 +102,8 @@ func (p *meterProvider) Meter(name string, opts ...metric.MeterOption) metric.Me
|
|||
// All Meter functionality is forwarded to a delegate once configured.
|
||||
// Otherwise, all functionality is forwarded to a NoopMeter.
|
||||
type meter struct {
|
||||
embedded.Meter
|
||||
|
||||
name string
|
||||
opts []metric.MeterOption
|
||||
|
||||
|
|
@ -142,7 +146,7 @@ func (m *meter) setDelegate(provider metric.MeterProvider) {
|
|||
m.registry.Init()
|
||||
}
|
||||
|
||||
func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error) {
|
||||
func (m *meter) Int64Counter(name string, options ...metric.Int64CounterOption) (metric.Int64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Counter(name, options...)
|
||||
}
|
||||
|
|
@ -153,7 +157,7 @@ func (m *meter) Int64Counter(name string, options ...instrument.Int64Option) (in
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
|
||||
func (m *meter) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) (metric.Int64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64UpDownCounter(name, options...)
|
||||
}
|
||||
|
|
@ -164,7 +168,7 @@ func (m *meter) Int64UpDownCounter(name string, options ...instrument.Int64Optio
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error) {
|
||||
func (m *meter) Int64Histogram(name string, options ...metric.Int64HistogramOption) (metric.Int64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64Histogram(name, options...)
|
||||
}
|
||||
|
|
@ -175,7 +179,7 @@ func (m *meter) Int64Histogram(name string, options ...instrument.Int64Option) (
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
|
||||
func (m *meter) Int64ObservableCounter(name string, options ...metric.Int64ObservableCounterOption) (metric.Int64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableCounter(name, options...)
|
||||
}
|
||||
|
|
@ -186,7 +190,7 @@ func (m *meter) Int64ObservableCounter(name string, options ...instrument.Int64O
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Int64ObservableUpDownCounter(name string, options ...metric.Int64ObservableUpDownCounterOption) (metric.Int64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
|
|
@ -197,7 +201,7 @@ func (m *meter) Int64ObservableUpDownCounter(name string, options ...instrument.
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
|
||||
func (m *meter) Int64ObservableGauge(name string, options ...metric.Int64ObservableGaugeOption) (metric.Int64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Int64ObservableGauge(name, options...)
|
||||
}
|
||||
|
|
@ -208,7 +212,7 @@ func (m *meter) Int64ObservableGauge(name string, options ...instrument.Int64Obs
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error) {
|
||||
func (m *meter) Float64Counter(name string, options ...metric.Float64CounterOption) (metric.Float64Counter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Counter(name, options...)
|
||||
}
|
||||
|
|
@ -219,7 +223,7 @@ func (m *meter) Float64Counter(name string, options ...instrument.Float64Option)
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
|
||||
func (m *meter) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) (metric.Float64UpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64UpDownCounter(name, options...)
|
||||
}
|
||||
|
|
@ -230,7 +234,7 @@ func (m *meter) Float64UpDownCounter(name string, options ...instrument.Float64O
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error) {
|
||||
func (m *meter) Float64Histogram(name string, options ...metric.Float64HistogramOption) (metric.Float64Histogram, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64Histogram(name, options...)
|
||||
}
|
||||
|
|
@ -241,7 +245,7 @@ func (m *meter) Float64Histogram(name string, options ...instrument.Float64Optio
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
|
||||
func (m *meter) Float64ObservableCounter(name string, options ...metric.Float64ObservableCounterOption) (metric.Float64ObservableCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableCounter(name, options...)
|
||||
}
|
||||
|
|
@ -252,7 +256,7 @@ func (m *meter) Float64ObservableCounter(name string, options ...instrument.Floa
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
func (m *meter) Float64ObservableUpDownCounter(name string, options ...metric.Float64ObservableUpDownCounterOption) (metric.Float64ObservableUpDownCounter, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableUpDownCounter(name, options...)
|
||||
}
|
||||
|
|
@ -263,7 +267,7 @@ func (m *meter) Float64ObservableUpDownCounter(name string, options ...instrumen
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
|
||||
func (m *meter) Float64ObservableGauge(name string, options ...metric.Float64ObservableGaugeOption) (metric.Float64ObservableGauge, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
return del.Float64ObservableGauge(name, options...)
|
||||
}
|
||||
|
|
@ -275,7 +279,7 @@ func (m *meter) Float64ObservableGauge(name string, options ...instrument.Float6
|
|||
}
|
||||
|
||||
// RegisterCallback captures the function that will be called during Collect.
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchronous) (metric.Registration, error) {
|
||||
func (m *meter) RegisterCallback(f metric.Callback, insts ...metric.Observable) (metric.Registration, error) {
|
||||
if del, ok := m.delegate.Load().(metric.Meter); ok {
|
||||
insts = unwrapInstruments(insts)
|
||||
return del.RegisterCallback(f, insts...)
|
||||
|
|
@ -296,11 +300,11 @@ func (m *meter) RegisterCallback(f metric.Callback, insts ...instrument.Asynchro
|
|||
}
|
||||
|
||||
type wrapped interface {
|
||||
unwrap() instrument.Asynchronous
|
||||
unwrap() metric.Observable
|
||||
}
|
||||
|
||||
func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Asynchronous {
|
||||
out := make([]instrument.Asynchronous, 0, len(instruments))
|
||||
func unwrapInstruments(instruments []metric.Observable) []metric.Observable {
|
||||
out := make([]metric.Observable, 0, len(instruments))
|
||||
|
||||
for _, inst := range instruments {
|
||||
if in, ok := inst.(wrapped); ok {
|
||||
|
|
@ -314,7 +318,9 @@ func unwrapInstruments(instruments []instrument.Asynchronous) []instrument.Async
|
|||
}
|
||||
|
||||
type registration struct {
|
||||
instruments []instrument.Asynchronous
|
||||
embedded.Registration
|
||||
|
||||
instruments []metric.Observable
|
||||
function metric.Callback
|
||||
|
||||
unreg func() error
|
||||
|
|
|
|||
81
vendor/go.opentelemetry.io/otel/metric/meter.go
generated
vendored
81
vendor/go.opentelemetry.io/otel/metric/meter.go
generated
vendored
|
|
@ -17,80 +17,91 @@ package metric // import "go.opentelemetry.io/otel/metric"
|
|||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// MeterProvider provides access to named Meter instances, for instrumenting
|
||||
// an application or library.
|
||||
// an application or package.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type MeterProvider interface {
|
||||
// Meter creates an instance of a `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
|
||||
embedded.MeterProvider
|
||||
|
||||
// Meter returns a new Meter with the provided name and configuration.
|
||||
//
|
||||
// A Meter should be scoped at most to a single package. The name needs to
|
||||
// be unique so it does not collide with other names used by
|
||||
// an application, nor other applications. To achieve this, the import path
|
||||
// of the instrumentation package is recommended to be used as name.
|
||||
//
|
||||
// If the name is empty, then an implementation defined default name will
|
||||
// be used instead.
|
||||
Meter(name string, opts ...MeterOption) Meter
|
||||
}
|
||||
|
||||
// Meter provides access to instrument instances for recording metrics.
|
||||
//
|
||||
// Warning: methods may be added to this interface in minor releases.
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Meter interface {
|
||||
embedded.Meter
|
||||
|
||||
// Int64Counter returns a new instrument identified by name and configured
|
||||
// with options. The instrument is used to synchronously record increasing
|
||||
// int64 measurements during a computational operation.
|
||||
Int64Counter(name string, options ...instrument.Int64Option) (instrument.Int64Counter, error)
|
||||
Int64Counter(name string, options ...Int64CounterOption) (Int64Counter, error)
|
||||
// Int64UpDownCounter returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to synchronously record
|
||||
// int64 measurements during a computational operation.
|
||||
Int64UpDownCounter(name string, options ...instrument.Int64Option) (instrument.Int64UpDownCounter, error)
|
||||
Int64UpDownCounter(name string, options ...Int64UpDownCounterOption) (Int64UpDownCounter, error)
|
||||
// Int64Histogram returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to synchronously record
|
||||
// the distribution of int64 measurements during a computational operation.
|
||||
Int64Histogram(name string, options ...instrument.Int64Option) (instrument.Int64Histogram, error)
|
||||
Int64Histogram(name string, options ...Int64HistogramOption) (Int64Histogram, error)
|
||||
// Int64ObservableCounter returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// increasing int64 measurements once per a measurement collection cycle.
|
||||
Int64ObservableCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error)
|
||||
Int64ObservableCounter(name string, options ...Int64ObservableCounterOption) (Int64ObservableCounter, error)
|
||||
// Int64ObservableUpDownCounter returns a new instrument identified by name
|
||||
// and configured with options. The instrument is used to asynchronously
|
||||
// record int64 measurements once per a measurement collection cycle.
|
||||
Int64ObservableUpDownCounter(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error)
|
||||
Int64ObservableUpDownCounter(name string, options ...Int64ObservableUpDownCounterOption) (Int64ObservableUpDownCounter, error)
|
||||
// Int64ObservableGauge returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// instantaneous int64 measurements once per a measurement collection
|
||||
// cycle.
|
||||
Int64ObservableGauge(name string, options ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error)
|
||||
Int64ObservableGauge(name string, options ...Int64ObservableGaugeOption) (Int64ObservableGauge, error)
|
||||
|
||||
// Float64Counter returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to synchronously record
|
||||
// increasing float64 measurements during a computational operation.
|
||||
Float64Counter(name string, options ...instrument.Float64Option) (instrument.Float64Counter, error)
|
||||
Float64Counter(name string, options ...Float64CounterOption) (Float64Counter, error)
|
||||
// Float64UpDownCounter returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to synchronously record
|
||||
// float64 measurements during a computational operation.
|
||||
Float64UpDownCounter(name string, options ...instrument.Float64Option) (instrument.Float64UpDownCounter, error)
|
||||
Float64UpDownCounter(name string, options ...Float64UpDownCounterOption) (Float64UpDownCounter, error)
|
||||
// Float64Histogram returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to synchronously record
|
||||
// the distribution of float64 measurements during a computational
|
||||
// operation.
|
||||
Float64Histogram(name string, options ...instrument.Float64Option) (instrument.Float64Histogram, error)
|
||||
Float64Histogram(name string, options ...Float64HistogramOption) (Float64Histogram, error)
|
||||
// Float64ObservableCounter returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// increasing float64 measurements once per a measurement collection cycle.
|
||||
Float64ObservableCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error)
|
||||
Float64ObservableCounter(name string, options ...Float64ObservableCounterOption) (Float64ObservableCounter, error)
|
||||
// Float64ObservableUpDownCounter returns a new instrument identified by
|
||||
// name and configured with options. The instrument is used to
|
||||
// asynchronously record float64 measurements once per a measurement
|
||||
// collection cycle.
|
||||
Float64ObservableUpDownCounter(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error)
|
||||
Float64ObservableUpDownCounter(name string, options ...Float64ObservableUpDownCounterOption) (Float64ObservableUpDownCounter, error)
|
||||
// Float64ObservableGauge returns a new instrument identified by name and
|
||||
// configured with options. The instrument is used to asynchronously record
|
||||
// instantaneous float64 measurements once per a measurement collection
|
||||
// cycle.
|
||||
Float64ObservableGauge(name string, options ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error)
|
||||
Float64ObservableGauge(name string, options ...Float64ObservableGaugeOption) (Float64ObservableGauge, error)
|
||||
|
||||
// RegisterCallback registers f to be called during the collection of a
|
||||
// measurement cycle.
|
||||
|
|
@ -103,12 +114,12 @@ type Meter interface {
|
|||
//
|
||||
// If no instruments are passed, f should not be registered nor called
|
||||
// during collection.
|
||||
RegisterCallback(f Callback, instruments ...instrument.Asynchronous) (Registration, error)
|
||||
RegisterCallback(f Callback, instruments ...Observable) (Registration, error)
|
||||
}
|
||||
|
||||
// Callback is a function registered with a Meter that makes observations for
|
||||
// the set of instruments it is registered with. The Observer parameter is used
|
||||
// to record measurment observations for these instruments.
|
||||
// to record measurement observations for these instruments.
|
||||
//
|
||||
// The function needs to complete in a finite amount of time and the deadline
|
||||
// of the passed context is expected to be honored.
|
||||
|
|
@ -121,16 +132,28 @@ type Meter interface {
|
|||
type Callback func(context.Context, Observer) error
|
||||
|
||||
// Observer records measurements for multiple instruments in a Callback.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Observer interface {
|
||||
// ObserveFloat64 records the float64 value with attributes for obsrv.
|
||||
ObserveFloat64(obsrv instrument.Float64Observable, value float64, attributes ...attribute.KeyValue)
|
||||
// ObserveInt64 records the int64 value with attributes for obsrv.
|
||||
ObserveInt64(obsrv instrument.Int64Observable, value int64, attributes ...attribute.KeyValue)
|
||||
embedded.Observer
|
||||
|
||||
// ObserveFloat64 records the float64 value for obsrv.
|
||||
ObserveFloat64(obsrv Float64Observable, value float64, opts ...ObserveOption)
|
||||
// ObserveInt64 records the int64 value for obsrv.
|
||||
ObserveInt64(obsrv Int64Observable, value int64, opts ...ObserveOption)
|
||||
}
|
||||
|
||||
// Registration is an token representing the unique registration of a callback
|
||||
// for a set of instruments with a Meter.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// package documentation on API implementation for information on how to set
|
||||
// default behavior for unimplemented methods.
|
||||
type Registration interface {
|
||||
embedded.Registration
|
||||
|
||||
// Unregister removes the callback registration from a Meter.
|
||||
//
|
||||
// This method needs to be idempotent and concurrent safe.
|
||||
|
|
|
|||
198
vendor/go.opentelemetry.io/otel/metric/noop.go
generated
vendored
198
vendor/go.opentelemetry.io/otel/metric/noop.go
generated
vendored
|
|
@ -1,198 +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 metric // import "go.opentelemetry.io/otel/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/metric/instrument"
|
||||
)
|
||||
|
||||
// NewNoopMeterProvider creates a MeterProvider that does not record any metrics.
|
||||
func NewNoopMeterProvider() MeterProvider {
|
||||
return noopMeterProvider{}
|
||||
}
|
||||
|
||||
type noopMeterProvider struct{}
|
||||
|
||||
func (noopMeterProvider) Meter(string, ...MeterOption) Meter {
|
||||
return noopMeter{}
|
||||
}
|
||||
|
||||
// NewNoopMeter creates a Meter that does not record any metrics.
|
||||
func NewNoopMeter() Meter {
|
||||
return noopMeter{}
|
||||
}
|
||||
|
||||
type noopMeter struct{}
|
||||
|
||||
func (noopMeter) Int64Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) {
|
||||
return nonrecordingSyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64ObservableCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
|
||||
return nonrecordingAsyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64ObservableUpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
return nonrecordingAsyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Int64ObservableGauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
|
||||
return nonrecordingAsyncInt64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) {
|
||||
return nonrecordingSyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
|
||||
return nonrecordingSyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) {
|
||||
return nonrecordingSyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64ObservableCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
|
||||
return nonrecordingAsyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64ObservableUpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
return nonrecordingAsyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
func (noopMeter) Float64ObservableGauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
|
||||
return nonrecordingAsyncFloat64Instrument{}, nil
|
||||
}
|
||||
|
||||
// RegisterCallback creates a register callback that does not record any metrics.
|
||||
func (noopMeter) RegisterCallback(Callback, ...instrument.Asynchronous) (Registration, error) {
|
||||
return noopReg{}, nil
|
||||
}
|
||||
|
||||
type noopReg struct{}
|
||||
|
||||
func (noopReg) Unregister() error { return nil }
|
||||
|
||||
type nonrecordingAsyncFloat64Instrument struct {
|
||||
instrument.Float64Observable
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Float64ObservableCounter = nonrecordingAsyncFloat64Instrument{}
|
||||
_ instrument.Float64ObservableUpDownCounter = nonrecordingAsyncFloat64Instrument{}
|
||||
_ instrument.Float64ObservableGauge = nonrecordingAsyncFloat64Instrument{}
|
||||
)
|
||||
|
||||
func (n nonrecordingAsyncFloat64Instrument) Counter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingAsyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableUpDownCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingAsyncFloat64Instrument) Gauge(string, ...instrument.Float64ObserverOption) (instrument.Float64ObservableGauge, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
type nonrecordingAsyncInt64Instrument struct {
|
||||
instrument.Int64Observable
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Int64ObservableCounter = nonrecordingAsyncInt64Instrument{}
|
||||
_ instrument.Int64ObservableUpDownCounter = nonrecordingAsyncInt64Instrument{}
|
||||
_ instrument.Int64ObservableGauge = nonrecordingAsyncInt64Instrument{}
|
||||
)
|
||||
|
||||
func (n nonrecordingAsyncInt64Instrument) Counter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingAsyncInt64Instrument) UpDownCounter(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableUpDownCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingAsyncInt64Instrument) Gauge(string, ...instrument.Int64ObserverOption) (instrument.Int64ObservableGauge, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
type nonrecordingSyncFloat64Instrument struct {
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Float64Counter = nonrecordingSyncFloat64Instrument{}
|
||||
_ instrument.Float64UpDownCounter = nonrecordingSyncFloat64Instrument{}
|
||||
_ instrument.Float64Histogram = nonrecordingSyncFloat64Instrument{}
|
||||
)
|
||||
|
||||
func (n nonrecordingSyncFloat64Instrument) Counter(string, ...instrument.Float64Option) (instrument.Float64Counter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingSyncFloat64Instrument) UpDownCounter(string, ...instrument.Float64Option) (instrument.Float64UpDownCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingSyncFloat64Instrument) Histogram(string, ...instrument.Float64Option) (instrument.Float64Histogram, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (nonrecordingSyncFloat64Instrument) Add(context.Context, float64, ...attribute.KeyValue) {
|
||||
|
||||
}
|
||||
|
||||
func (nonrecordingSyncFloat64Instrument) Record(context.Context, float64, ...attribute.KeyValue) {
|
||||
|
||||
}
|
||||
|
||||
type nonrecordingSyncInt64Instrument struct {
|
||||
instrument.Synchronous
|
||||
}
|
||||
|
||||
var (
|
||||
_ instrument.Int64Counter = nonrecordingSyncInt64Instrument{}
|
||||
_ instrument.Int64UpDownCounter = nonrecordingSyncInt64Instrument{}
|
||||
_ instrument.Int64Histogram = nonrecordingSyncInt64Instrument{}
|
||||
)
|
||||
|
||||
func (n nonrecordingSyncInt64Instrument) Counter(string, ...instrument.Int64Option) (instrument.Int64Counter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingSyncInt64Instrument) UpDownCounter(string, ...instrument.Int64Option) (instrument.Int64UpDownCounter, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (n nonrecordingSyncInt64Instrument) Histogram(string, ...instrument.Int64Option) (instrument.Int64Histogram, error) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (nonrecordingSyncInt64Instrument) Add(context.Context, int64, ...attribute.KeyValue) {
|
||||
}
|
||||
func (nonrecordingSyncInt64Instrument) Record(context.Context, int64, ...attribute.KeyValue) {
|
||||
}
|
||||
162
vendor/go.opentelemetry.io/otel/metric/syncfloat64.go
generated
vendored
Normal file
162
vendor/go.opentelemetry.io/otel/metric/syncfloat64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
// 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/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Float64Counter is an instrument that records increasing float64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64Counter interface {
|
||||
embedded.Float64Counter
|
||||
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr float64, opts ...AddOption)
|
||||
}
|
||||
|
||||
// Float64CounterConfig contains options for synchronous counter instruments that
|
||||
// record int64 values.
|
||||
type Float64CounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64CounterConfig returns a new [Float64CounterConfig] with all opts
|
||||
// applied.
|
||||
func NewFloat64CounterConfig(opts ...Float64CounterOption) Float64CounterConfig {
|
||||
var config Float64CounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64Counter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64CounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64CounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64CounterOption applies options to a [Float64CounterConfig]. See
|
||||
// [Option] for other options that can be used as a Float64CounterOption.
|
||||
type Float64CounterOption interface {
|
||||
applyFloat64Counter(Float64CounterConfig) Float64CounterConfig
|
||||
}
|
||||
|
||||
// Float64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// float64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64UpDownCounter interface {
|
||||
embedded.Float64UpDownCounter
|
||||
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr float64, opts ...AddOption)
|
||||
}
|
||||
|
||||
// Float64UpDownCounterConfig contains options for synchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Float64UpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64UpDownCounterConfig returns a new [Float64UpDownCounterConfig]
|
||||
// with all opts applied.
|
||||
func NewFloat64UpDownCounterConfig(opts ...Float64UpDownCounterOption) Float64UpDownCounterConfig {
|
||||
var config Float64UpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64UpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64UpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64UpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64UpDownCounterOption applies options to a
|
||||
// [Float64UpDownCounterConfig]. See [Option] for other options that can be
|
||||
// used as a Float64UpDownCounterOption.
|
||||
type Float64UpDownCounterOption interface {
|
||||
applyFloat64UpDownCounter(Float64UpDownCounterConfig) Float64UpDownCounterConfig
|
||||
}
|
||||
|
||||
// Float64Histogram is an instrument that records a distribution of float64
|
||||
// values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Float64Histogram interface {
|
||||
embedded.Float64Histogram
|
||||
|
||||
// Record adds an additional value to the distribution.
|
||||
Record(ctx context.Context, incr float64, opts ...RecordOption)
|
||||
}
|
||||
|
||||
// Float64HistogramConfig contains options for synchronous counter instruments
|
||||
// that record int64 values.
|
||||
type Float64HistogramConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewFloat64HistogramConfig returns a new [Float64HistogramConfig] with all
|
||||
// opts applied.
|
||||
func NewFloat64HistogramConfig(opts ...Float64HistogramOption) Float64HistogramConfig {
|
||||
var config Float64HistogramConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyFloat64Histogram(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Float64HistogramConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Float64HistogramConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Float64HistogramOption applies options to a [Float64HistogramConfig]. See
|
||||
// [Option] for other options that can be used as a Float64HistogramOption.
|
||||
type Float64HistogramOption interface {
|
||||
applyFloat64Histogram(Float64HistogramConfig) Float64HistogramConfig
|
||||
}
|
||||
162
vendor/go.opentelemetry.io/otel/metric/syncint64.go
generated
vendored
Normal file
162
vendor/go.opentelemetry.io/otel/metric/syncint64.go
generated
vendored
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
// 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/metric"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel/metric/embedded"
|
||||
)
|
||||
|
||||
// Int64Counter is an instrument that records increasing int64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64Counter interface {
|
||||
embedded.Int64Counter
|
||||
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, opts ...AddOption)
|
||||
}
|
||||
|
||||
// Int64CounterConfig contains options for synchronous counter instruments that
|
||||
// record int64 values.
|
||||
type Int64CounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64CounterConfig returns a new [Int64CounterConfig] with all opts
|
||||
// applied.
|
||||
func NewInt64CounterConfig(opts ...Int64CounterOption) Int64CounterConfig {
|
||||
var config Int64CounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64Counter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64CounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64CounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64CounterOption applies options to a [Int64CounterConfig]. See [Option]
|
||||
// for other options that can be used as an Int64CounterOption.
|
||||
type Int64CounterOption interface {
|
||||
applyInt64Counter(Int64CounterConfig) Int64CounterConfig
|
||||
}
|
||||
|
||||
// Int64UpDownCounter is an instrument that records increasing or decreasing
|
||||
// int64 values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64UpDownCounter interface {
|
||||
embedded.Int64UpDownCounter
|
||||
|
||||
// Add records a change to the counter.
|
||||
Add(ctx context.Context, incr int64, opts ...AddOption)
|
||||
}
|
||||
|
||||
// Int64UpDownCounterConfig contains options for synchronous counter
|
||||
// instruments that record int64 values.
|
||||
type Int64UpDownCounterConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64UpDownCounterConfig returns a new [Int64UpDownCounterConfig] with
|
||||
// all opts applied.
|
||||
func NewInt64UpDownCounterConfig(opts ...Int64UpDownCounterOption) Int64UpDownCounterConfig {
|
||||
var config Int64UpDownCounterConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64UpDownCounter(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64UpDownCounterConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64UpDownCounterConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64UpDownCounterOption applies options to a [Int64UpDownCounterConfig].
|
||||
// See [Option] for other options that can be used as an
|
||||
// Int64UpDownCounterOption.
|
||||
type Int64UpDownCounterOption interface {
|
||||
applyInt64UpDownCounter(Int64UpDownCounterConfig) Int64UpDownCounterConfig
|
||||
}
|
||||
|
||||
// Int64Histogram is an instrument that records a distribution of int64
|
||||
// values.
|
||||
//
|
||||
// Warning: Methods may be added to this interface in minor releases. See
|
||||
// [go.opentelemetry.io/otel/metric] package documentation on API
|
||||
// implementation for information on how to set default behavior for
|
||||
// unimplemented methods.
|
||||
type Int64Histogram interface {
|
||||
embedded.Int64Histogram
|
||||
|
||||
// Record adds an additional value to the distribution.
|
||||
Record(ctx context.Context, incr int64, opts ...RecordOption)
|
||||
}
|
||||
|
||||
// Int64HistogramConfig contains options for synchronous counter instruments
|
||||
// that record int64 values.
|
||||
type Int64HistogramConfig struct {
|
||||
description string
|
||||
unit string
|
||||
}
|
||||
|
||||
// NewInt64HistogramConfig returns a new [Int64HistogramConfig] with all opts
|
||||
// applied.
|
||||
func NewInt64HistogramConfig(opts ...Int64HistogramOption) Int64HistogramConfig {
|
||||
var config Int64HistogramConfig
|
||||
for _, o := range opts {
|
||||
config = o.applyInt64Histogram(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
// Description returns the configured description.
|
||||
func (c Int64HistogramConfig) Description() string {
|
||||
return c.description
|
||||
}
|
||||
|
||||
// Unit returns the configured unit.
|
||||
func (c Int64HistogramConfig) Unit() string {
|
||||
return c.unit
|
||||
}
|
||||
|
||||
// Int64HistogramOption applies options to a [Int64HistogramConfig]. See
|
||||
// [Option] for other options that can be used as an Int64HistogramOption.
|
||||
type Int64HistogramOption interface {
|
||||
applyInt64Histogram(Int64HistogramConfig) Int64HistogramConfig
|
||||
}
|
||||
20
vendor/go.opentelemetry.io/otel/metric/unit/doc.go
generated
vendored
20
vendor/go.opentelemetry.io/otel/metric/unit/doc.go
generated
vendored
|
|
@ -1,20 +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 unit provides units.
|
||||
//
|
||||
// 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 unit // import "go.opentelemetry.io/otel/metric/unit"
|
||||
25
vendor/go.opentelemetry.io/otel/metric/unit/unit.go
generated
vendored
25
vendor/go.opentelemetry.io/otel/metric/unit/unit.go
generated
vendored
|
|
@ -1,25 +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 unit // import "go.opentelemetry.io/otel/metric/unit"
|
||||
|
||||
// Unit is a determinate standard quantity of measurement.
|
||||
type Unit string
|
||||
|
||||
// Units defined by OpenTelemetry.
|
||||
const (
|
||||
Dimensionless Unit = "1"
|
||||
Bytes Unit = "By"
|
||||
Milliseconds Unit = "ms"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue