Documentation ¶
Overview ¶
Package metric provides an implementation of the metrics part of the OpenTelemetry API.
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.
Measurements can be made about an operation being performed or the state of a system in general. These measurements can be crucial to the reliable operation of code and provide valuable insights about the inner workings of a system.
Measurements are made using instruments provided by this package. The type of instrument used will depend on the type of measurement being made and of what part of a system is being measured.
Instruments are categorized as Synchronous or Asynchronous and independently as Adding or Grouping. Synchronous instruments are called by the user with a Context. Asynchronous instruments are called by the SDK during collection. Adding instruments are semantically intended for capturing a sum. Grouping instruments are intended for capturing a distribution.
Adding instruments may be monotonic, in which case they are non-decreasing and naturally define a rate.
The synchronous instrument names are:
Counter: adding, monotonic UpDownCounter: adding Histogram: grouping
and the asynchronous instruments are:
CounterObserver: adding, monotonic UpDownCounterObserver: adding GaugeObserver: grouping
All instruments are provided with support for either float64 or int64 input values.
An instrument is created using a Meter. Additionally, a Meter is used to record batches of synchronous measurements or asynchronous observations. A Meter is obtained using a MeterProvider. A Meter, like a Tracer, is unique to the instrumentation it instruments and must be named and versioned when created with a MeterProvider with the name and version of the instrumentation library.
Instrumentation should be designed to accept a MeterProvider from which it can create its own unique Meter. Alternatively, the registered global MeterProvider from the go.opentelemetry.io/otel package can be used as a default.
Index ¶
- Variables
- type AsyncBatchRunner
- type AsyncImpl
- type AsyncRunner
- type AsyncSingleRunner
- type BatchObserver
- func (b BatchObserver) NewFloat64CounterObserver(name string, opts ...InstrumentOption) (Float64CounterObserver, error)
- func (b BatchObserver) NewFloat64GaugeObserver(name string, opts ...InstrumentOption) (Float64GaugeObserver, error)
- func (b BatchObserver) NewFloat64UpDownCounterObserver(name string, opts ...InstrumentOption) (Float64UpDownCounterObserver, error)
- func (b BatchObserver) NewInt64CounterObserver(name string, opts ...InstrumentOption) (Int64CounterObserver, error)
- func (b BatchObserver) NewInt64GaugeObserver(name string, opts ...InstrumentOption) (Int64GaugeObserver, error)
- func (b BatchObserver) NewInt64UpDownCounterObserver(name string, opts ...InstrumentOption) (Int64UpDownCounterObserver, error)
- type BatchObserverFunc
- type BatchObserverMust
- func (bm BatchObserverMust) NewFloat64CounterObserver(name string, oos ...InstrumentOption) Float64CounterObserver
- func (bm BatchObserverMust) NewFloat64GaugeObserver(name string, oos ...InstrumentOption) Float64GaugeObserver
- func (bm BatchObserverMust) NewFloat64UpDownCounterObserver(name string, oos ...InstrumentOption) Float64UpDownCounterObserver
- func (bm BatchObserverMust) NewInt64CounterObserver(name string, oos ...InstrumentOption) Int64CounterObserver
- func (bm BatchObserverMust) NewInt64GaugeObserver(name string, oos ...InstrumentOption) Int64GaugeObserver
- func (bm BatchObserverMust) NewInt64UpDownCounterObserver(name string, oos ...InstrumentOption) Int64UpDownCounterObserver
- type BatchObserverResult
- type BoundFloat64Counter
- type BoundFloat64Histogram
- type BoundFloat64UpDownCounter
- type BoundInt64Counter
- type BoundInt64Histogram
- type BoundInt64UpDownCounter
- type BoundSyncImpl
- type Descriptor
- func (d Descriptor) Description() string
- func (d Descriptor) InstrumentKind() sdkapi.InstrumentKind
- func (d Descriptor) InstrumentationName() string
- func (d Descriptor) InstrumentationVersion() string
- func (d Descriptor) Name() string
- func (d Descriptor) NumberKind() number.Kind
- func (d Descriptor) Unit() unit.Unit
- type Float64Counter
- type Float64CounterObserver
- type Float64GaugeObserver
- type Float64Histogram
- type Float64ObserverFunc
- type Float64ObserverResult
- type Float64UpDownCounter
- func (c Float64UpDownCounter) Add(ctx context.Context, value float64, labels ...attribute.KeyValue)
- func (c Float64UpDownCounter) Bind(labels ...attribute.KeyValue) (h BoundFloat64UpDownCounter)
- func (c Float64UpDownCounter) Measurement(value float64) Measurement
- func (s Float64UpDownCounter) SyncImpl() SyncImpl
- type Float64UpDownCounterObserver
- type InstrumentConfig
- type InstrumentImpl
- type InstrumentMeterOption
- type InstrumentOption
- type Int64Counter
- type Int64CounterObserver
- type Int64GaugeObserver
- type Int64Histogram
- type Int64ObserverFunc
- type Int64ObserverResult
- type Int64UpDownCounter
- type Int64UpDownCounterObserver
- type Measurement
- type Meter
- func (m Meter) MeterImpl() MeterImpl
- func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver
- func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error)
- func (m Meter) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64CounterObserver, error)
- func (m Meter) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64GaugeObserver, error)
- func (m Meter) NewFloat64Histogram(name string, opts ...InstrumentOption) (Float64Histogram, error)
- func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error)
- func (m Meter) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownCounterObserver, error)
- func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error)
- func (m Meter) NewInt64CounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64CounterObserver, error)
- func (m Meter) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64GaugeObserver, error)
- func (m Meter) NewInt64Histogram(name string, opts ...InstrumentOption) (Int64Histogram, error)
- func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error)
- func (m Meter) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownCounterObserver, error)
- func (m Meter) RecordBatch(ctx context.Context, ls []attribute.KeyValue, ms ...Measurement)
- type MeterConfig
- type MeterImpl
- type MeterMust
- func (mm MeterMust) NewBatchObserver(callback BatchObserverFunc) BatchObserverMust
- func (mm MeterMust) NewFloat64Counter(name string, cos ...InstrumentOption) Float64Counter
- func (mm MeterMust) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64CounterObserver
- func (mm MeterMust) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64GaugeObserver
- func (mm MeterMust) NewFloat64Histogram(name string, mos ...InstrumentOption) Float64Histogram
- func (mm MeterMust) NewFloat64UpDownCounter(name string, cos ...InstrumentOption) Float64UpDownCounter
- func (mm MeterMust) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownCounterObserver
- func (mm MeterMust) NewInt64Counter(name string, cos ...InstrumentOption) Int64Counter
- func (mm MeterMust) NewInt64CounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64CounterObserver
- func (mm MeterMust) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64GaugeObserver
- func (mm MeterMust) NewInt64Histogram(name string, mos ...InstrumentOption) Int64Histogram
- func (mm MeterMust) NewInt64UpDownCounter(name string, cos ...InstrumentOption) Int64UpDownCounter
- func (mm MeterMust) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownCounterObserver
- type MeterOption
- type MeterProvider
- type NoopAsync
- type NoopMeterProvider
- type NoopSync
- type Observation
- type SyncImpl
Constants ¶
This section is empty.
Variables ¶
var ErrSDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
ErrSDKReturnedNilImpl is returned when a new `MeterImpl` returns nil.
Functions ¶
This section is empty.
Types ¶
type AsyncBatchRunner ¶
type AsyncBatchRunner interface { // Run accepts a function for capturing observations of // multiple instruments. Run(ctx context.Context, capture func([]attribute.KeyValue, ...Observation)) AsyncRunner }
AsyncBatchRunner is an interface implemented by batch-observer callbacks.
type AsyncImpl ¶
type AsyncImpl interface { InstrumentImpl }
AsyncImpl is an implementation-level interface to an asynchronous instrument (e.g., Observer instruments).
type AsyncRunner ¶
type AsyncRunner interface { // AnyRunner() is a non-exported method with no functional use // other than to make this a non-empty interface. AnyRunner() }
AsyncRunner is expected to convert into an AsyncSingleRunner or an AsyncBatchRunner. SDKs will encounter an error if the AsyncRunner does not satisfy one of these interfaces.
type AsyncSingleRunner ¶
type AsyncSingleRunner interface { // Run accepts a single instrument and function for capturing // observations of that instrument. Each call to the function // receives one captured observation. (The function accepts // multiple observations so the same implementation can be // used for batch runners.) Run(ctx context.Context, single AsyncImpl, capture func([]attribute.KeyValue, ...Observation)) AsyncRunner }
AsyncSingleRunner is an interface implemented by single-observer callbacks.
type BatchObserver ¶
type BatchObserver struct {
// contains filtered or unexported fields
}
BatchObserver represents an Observer callback that can report observations for multiple instruments.
func (BatchObserver) NewFloat64CounterObserver ¶ added in v0.23.0
func (b BatchObserver) NewFloat64CounterObserver(name string, opts ...InstrumentOption) (Float64CounterObserver, error)
NewFloat64CounterObserver creates a new floating point CounterObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (BatchObserver) NewFloat64GaugeObserver ¶ added in v0.23.0
func (b BatchObserver) NewFloat64GaugeObserver(name string, opts ...InstrumentOption) (Float64GaugeObserver, error)
NewFloat64GaugeObserver creates a new floating point GaugeObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (BatchObserver) NewFloat64UpDownCounterObserver ¶ added in v0.23.0
func (b BatchObserver) NewFloat64UpDownCounterObserver(name string, opts ...InstrumentOption) (Float64UpDownCounterObserver, error)
NewFloat64UpDownCounterObserver creates a new floating point UpDownCounterObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (BatchObserver) NewInt64CounterObserver ¶ added in v0.23.0
func (b BatchObserver) NewInt64CounterObserver(name string, opts ...InstrumentOption) (Int64CounterObserver, error)
NewInt64CounterObserver creates a new integer CounterObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (BatchObserver) NewInt64GaugeObserver ¶ added in v0.23.0
func (b BatchObserver) NewInt64GaugeObserver(name string, opts ...InstrumentOption) (Int64GaugeObserver, error)
NewInt64GaugeObserver creates a new integer GaugeObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (BatchObserver) NewInt64UpDownCounterObserver ¶ added in v0.23.0
func (b BatchObserver) NewInt64UpDownCounterObserver(name string, opts ...InstrumentOption) (Int64UpDownCounterObserver, error)
NewInt64UpDownCounterObserver creates a new integer UpDownCounterObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
type BatchObserverFunc ¶
type BatchObserverFunc func(context.Context, BatchObserverResult)
BatchObserverFunc is a callback argument for use with any Observer instrument that will be reported as a batch of observations.
func (*BatchObserverFunc) AnyRunner ¶
func (*BatchObserverFunc) AnyRunner()
AnyRunner implements AsyncRunner.
func (*BatchObserverFunc) Run ¶
func (b *BatchObserverFunc) Run(ctx context.Context, function func([]attribute.KeyValue, ...Observation))
Run implements AsyncBatchRunner.
type BatchObserverMust ¶
type BatchObserverMust struct {
// contains filtered or unexported fields
}
BatchObserverMust is a wrapper for BatchObserver that panics when any instrument constructor encounters an error.
func (BatchObserverMust) NewFloat64CounterObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewFloat64CounterObserver(name string, oos ...InstrumentOption) Float64CounterObserver
NewFloat64CounterObserver calls `BatchObserver.NewFloat64CounterObserver` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) NewFloat64GaugeObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewFloat64GaugeObserver(name string, oos ...InstrumentOption) Float64GaugeObserver
NewFloat64GaugeObserver calls `BatchObserver.NewFloat64GaugeObserver` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) NewFloat64UpDownCounterObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewFloat64UpDownCounterObserver(name string, oos ...InstrumentOption) Float64UpDownCounterObserver
NewFloat64UpDownCounterObserver calls `BatchObserver.NewFloat64UpDownCounterObserver` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) NewInt64CounterObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewInt64CounterObserver(name string, oos ...InstrumentOption) Int64CounterObserver
NewInt64CounterObserver calls `BatchObserver.NewInt64CounterObserver` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) NewInt64GaugeObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewInt64GaugeObserver(name string, oos ...InstrumentOption) Int64GaugeObserver
NewInt64GaugeObserver calls `BatchObserver.NewInt64GaugeObserver` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) NewInt64UpDownCounterObserver ¶ added in v0.23.0
func (bm BatchObserverMust) NewInt64UpDownCounterObserver(name string, oos ...InstrumentOption) Int64UpDownCounterObserver
NewInt64UpDownCounterObserver calls `BatchObserver.NewInt64UpDownCounterObserver` and returns the instrument, panicking if it encounters an error.
type BatchObserverResult ¶
type BatchObserverResult struct {
// contains filtered or unexported fields
}
BatchObserverResult is passed to a batch observer callback to capture observations for multiple asynchronous instruments.
func (BatchObserverResult) Observe ¶
func (br BatchObserverResult) Observe(labels []attribute.KeyValue, obs ...Observation)
Observe captures a multiple observations from the associated batch instrument callback, with the given labels.
type BoundFloat64Counter ¶
type BoundFloat64Counter struct {
// contains filtered or unexported fields
}
BoundFloat64Counter is a bound instrument for Float64Counter.
It inherits the Unbind function from syncBoundInstrument.
type BoundFloat64Histogram ¶ added in v0.23.0
type BoundFloat64Histogram struct {
// contains filtered or unexported fields
}
BoundFloat64Histogram is a bound instrument for Float64Histogram.
It inherits the Unbind function from syncBoundInstrument.
type BoundFloat64UpDownCounter ¶
type BoundFloat64UpDownCounter struct {
// contains filtered or unexported fields
}
BoundFloat64UpDownCounter is a bound instrument for Float64UpDownCounter.
It inherits the Unbind function from syncBoundInstrument.
type BoundInt64Counter ¶
type BoundInt64Counter struct {
// contains filtered or unexported fields
}
BoundInt64Counter is a boundInstrument for Int64Counter.
It inherits the Unbind function from syncBoundInstrument.
type BoundInt64Histogram ¶ added in v0.23.0
type BoundInt64Histogram struct {
// contains filtered or unexported fields
}
BoundInt64Histogram is a bound instrument for Int64Histogram.
It inherits the Unbind function from syncBoundInstrument.
type BoundInt64UpDownCounter ¶
type BoundInt64UpDownCounter struct {
// contains filtered or unexported fields
}
BoundInt64UpDownCounter is a boundInstrument for Int64UpDownCounter.
It inherits the Unbind function from syncBoundInstrument.
type BoundSyncImpl ¶
type BoundSyncImpl interface { // RecordOne captures a single synchronous metric event. RecordOne(ctx context.Context, number number.Number) // Unbind frees the resources associated with this bound instrument. It // does not affect the metric this bound instrument was created through. Unbind() }
BoundSyncImpl is the implementation-level interface to a generic bound synchronous instrument
type Descriptor ¶
type Descriptor struct {
// contains filtered or unexported fields
}
Descriptor contains all the settings that describe an instrument, including its name, metric kind, number kind, and the configurable options.
func NewDescriptor ¶
func NewDescriptor(name string, ikind sdkapi.InstrumentKind, nkind number.Kind, opts ...InstrumentOption) Descriptor
NewDescriptor returns a Descriptor with the given contents.
func (Descriptor) Description ¶
func (d Descriptor) Description() string
Description provides a human-readable description of the metric instrument.
func (Descriptor) InstrumentKind ¶
func (d Descriptor) InstrumentKind() sdkapi.InstrumentKind
InstrumentKind returns the specific kind of instrument.
func (Descriptor) InstrumentationName ¶
func (d Descriptor) InstrumentationName() string
InstrumentationName returns the name of the library that provided instrumentation for this instrument.
func (Descriptor) InstrumentationVersion ¶
func (d Descriptor) InstrumentationVersion() string
InstrumentationVersion returns the version of the library that provided instrumentation for this instrument.
func (Descriptor) Name ¶
func (d Descriptor) Name() string
Name returns the metric instrument's name.
func (Descriptor) NumberKind ¶
func (d Descriptor) NumberKind() number.Kind
NumberKind returns whether this instrument is declared over int64, float64, or uint64 values.
func (Descriptor) Unit ¶
func (d Descriptor) Unit() unit.Unit
Unit describes the units of the metric instrument. Unitless metrics return the empty string.
type Float64Counter ¶
type Float64Counter struct {
// contains filtered or unexported fields
}
Float64Counter is a metric that accumulates float64 values.
func (Float64Counter) Add ¶
Add adds the value to the counter's sum. The labels should contain the keys and values to be associated with this value.
func (Float64Counter) Bind ¶
func (c Float64Counter) Bind(labels ...attribute.KeyValue) (h BoundFloat64Counter)
Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.
func (Float64Counter) Measurement ¶
func (c Float64Counter) Measurement(value float64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Float64CounterObserver ¶ added in v0.23.0
type Float64CounterObserver struct {
// contains filtered or unexported fields
}
Float64CounterObserver is a metric that captures a precomputed sum of float64 values at a point in time.
func (Float64CounterObserver) AsyncImpl ¶ added in v0.23.0
func (a Float64CounterObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Float64CounterObserver) Observation ¶ added in v0.23.0
func (f Float64CounterObserver) Observation(v float64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Float64GaugeObserver ¶ added in v0.23.0
type Float64GaugeObserver struct {
// contains filtered or unexported fields
}
Float64GaugeObserver is a metric that captures a set of float64 values at a point in time.
func (Float64GaugeObserver) AsyncImpl ¶ added in v0.23.0
func (a Float64GaugeObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Float64GaugeObserver) Observation ¶ added in v0.23.0
func (f Float64GaugeObserver) Observation(v float64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Float64Histogram ¶ added in v0.23.0
type Float64Histogram struct {
// contains filtered or unexported fields
}
Float64Histogram is a metric that records float64 values.
func (Float64Histogram) Bind ¶ added in v0.23.0
func (c Float64Histogram) Bind(labels ...attribute.KeyValue) (h BoundFloat64Histogram)
Bind creates a bound instrument for this Histogram. The labels are associated with values recorded via subsequent calls to Record.
func (Float64Histogram) Measurement ¶ added in v0.23.0
func (c Float64Histogram) Measurement(value float64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Float64ObserverFunc ¶
type Float64ObserverFunc func(context.Context, Float64ObserverResult)
Float64ObserverFunc is a type of callback that floating point observers run.
func (*Float64ObserverFunc) AnyRunner ¶
func (*Float64ObserverFunc) AnyRunner()
AnyRunner implements AsyncRunner.
func (*Float64ObserverFunc) Run ¶
func (f *Float64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]attribute.KeyValue, ...Observation))
Run implements AsyncSingleRunner.
type Float64ObserverResult ¶
type Float64ObserverResult struct {
// contains filtered or unexported fields
}
Float64ObserverResult is passed to an observer callback to capture observations for one asynchronous floating point metric instrument.
type Float64UpDownCounter ¶
type Float64UpDownCounter struct {
// contains filtered or unexported fields
}
Float64UpDownCounter is a metric instrument that sums floating point values.
func (Float64UpDownCounter) Add ¶
Add adds the value to the counter's sum. The labels should contain the keys and values to be associated with this value.
func (Float64UpDownCounter) Bind ¶
func (c Float64UpDownCounter) Bind(labels ...attribute.KeyValue) (h BoundFloat64UpDownCounter)
Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.
func (Float64UpDownCounter) Measurement ¶
func (c Float64UpDownCounter) Measurement(value float64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Float64UpDownCounterObserver ¶ added in v0.23.0
type Float64UpDownCounterObserver struct {
// contains filtered or unexported fields
}
Float64UpDownCounterObserver is a metric that captures a precomputed sum of float64 values at a point in time.
func (Float64UpDownCounterObserver) AsyncImpl ¶ added in v0.23.0
func (a Float64UpDownCounterObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Float64UpDownCounterObserver) Observation ¶ added in v0.23.0
func (f Float64UpDownCounterObserver) Observation(v float64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type InstrumentConfig ¶
type InstrumentConfig struct {
// contains filtered or unexported fields
}
InstrumentConfig contains options for metric instrument descriptors.
func NewInstrumentConfig ¶
func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig
NewInstrumentConfig creates a new InstrumentConfig and applies all the given options.
func (InstrumentConfig) Description ¶
func (cfg InstrumentConfig) Description() string
Description describes the instrument in human-readable terms.
func (InstrumentConfig) InstrumentationName ¶
func (cfg InstrumentConfig) InstrumentationName() string
InstrumentationName is the name of the library providing instrumentation.
func (InstrumentConfig) InstrumentationVersion ¶
func (cfg InstrumentConfig) InstrumentationVersion() string
InstrumentationVersion is the version of the library providing instrumentation.
func (InstrumentConfig) Unit ¶
func (cfg InstrumentConfig) Unit() unit.Unit
Unit describes the measurement unit for a instrument.
type InstrumentImpl ¶
type InstrumentImpl interface { // Implementation returns the underlying implementation of the // instrument, which allows the implementation to gain access // to its own representation especially from a `Measurement`. Implementation() interface{} // Descriptor returns a copy of the instrument's Descriptor. Descriptor() Descriptor }
InstrumentImpl is a common interface for synchronous and asynchronous instruments.
type InstrumentMeterOption ¶ added in v0.21.0
type InstrumentMeterOption interface { InstrumentOption MeterOption }
InstrumentMeterOption are options that can be used as both an InstrumentOption and MeterOption
func WithInstrumentationVersion ¶
func WithInstrumentationVersion(version string) InstrumentMeterOption
WithInstrumentationVersion sets the instrumentation version.
type InstrumentOption ¶
type InstrumentOption interface {
// contains filtered or unexported methods
}
InstrumentOption is an interface for applying metric instrument options.
func WithDescription ¶
func WithDescription(desc string) InstrumentOption
WithDescription applies provided description.
func WithInstrumentationName ¶
func WithInstrumentationName(name string) InstrumentOption
WithInstrumentationName sets the instrumentation name.
type Int64Counter ¶
type Int64Counter struct {
// contains filtered or unexported fields
}
Int64Counter is a metric that accumulates int64 values.
func (Int64Counter) Add ¶
Add adds the value to the counter's sum. The labels should contain the keys and values to be associated with this value.
func (Int64Counter) Bind ¶
func (c Int64Counter) Bind(labels ...attribute.KeyValue) (h BoundInt64Counter)
Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.
func (Int64Counter) Measurement ¶
func (c Int64Counter) Measurement(value int64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Int64CounterObserver ¶ added in v0.23.0
type Int64CounterObserver struct {
// contains filtered or unexported fields
}
Int64CounterObserver is a metric that captures a precomputed sum of int64 values at a point in time.
func (Int64CounterObserver) AsyncImpl ¶ added in v0.23.0
func (a Int64CounterObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Int64CounterObserver) Observation ¶ added in v0.23.0
func (i Int64CounterObserver) Observation(v int64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Int64GaugeObserver ¶ added in v0.23.0
type Int64GaugeObserver struct {
// contains filtered or unexported fields
}
Int64GaugeObserver is a metric that captures a set of int64 values at a point in time.
func (Int64GaugeObserver) AsyncImpl ¶ added in v0.23.0
func (a Int64GaugeObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Int64GaugeObserver) Observation ¶ added in v0.23.0
func (i Int64GaugeObserver) Observation(v int64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Int64Histogram ¶ added in v0.23.0
type Int64Histogram struct {
// contains filtered or unexported fields
}
Int64Histogram is a metric that records int64 values.
func (Int64Histogram) Bind ¶ added in v0.23.0
func (c Int64Histogram) Bind(labels ...attribute.KeyValue) (h BoundInt64Histogram)
Bind creates a bound instrument for this Histogram. The labels are associated with values recorded via subsequent calls to Record.
func (Int64Histogram) Measurement ¶ added in v0.23.0
func (c Int64Histogram) Measurement(value int64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Int64ObserverFunc ¶
type Int64ObserverFunc func(context.Context, Int64ObserverResult)
Int64ObserverFunc is a type of callback that integral observers run.
func (*Int64ObserverFunc) AnyRunner ¶
func (*Int64ObserverFunc) AnyRunner()
AnyRunner implements AsyncRunner.
func (*Int64ObserverFunc) Run ¶
func (i *Int64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]attribute.KeyValue, ...Observation))
Run implements AsyncSingleRunner.
type Int64ObserverResult ¶
type Int64ObserverResult struct {
// contains filtered or unexported fields
}
Int64ObserverResult is passed to an observer callback to capture observations for one asynchronous integer metric instrument.
type Int64UpDownCounter ¶
type Int64UpDownCounter struct {
// contains filtered or unexported fields
}
Int64UpDownCounter is a metric instrument that sums integer values.
func (Int64UpDownCounter) Add ¶
Add adds the value to the counter's sum. The labels should contain the keys and values to be associated with this value.
func (Int64UpDownCounter) Bind ¶
func (c Int64UpDownCounter) Bind(labels ...attribute.KeyValue) (h BoundInt64UpDownCounter)
Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.
func (Int64UpDownCounter) Measurement ¶
func (c Int64UpDownCounter) Measurement(value int64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Int64UpDownCounterObserver ¶ added in v0.23.0
type Int64UpDownCounterObserver struct {
// contains filtered or unexported fields
}
Int64UpDownCounterObserver is a metric that captures a precomputed sum of int64 values at a point in time.
func (Int64UpDownCounterObserver) AsyncImpl ¶ added in v0.23.0
func (a Int64UpDownCounterObserver) AsyncImpl() AsyncImpl
AsyncImpl implements AsyncImpl.
func (Int64UpDownCounterObserver) Observation ¶ added in v0.23.0
func (i Int64UpDownCounterObserver) Observation(v int64) Observation
Observation returns an Observation, a BatchObserverFunc argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Measurement ¶
type Measurement struct {
// contains filtered or unexported fields
}
Measurement is used for reporting a synchronous batch of metric values. Instances of this type should be created by synchronous instruments (e.g., Int64Counter.Measurement()).
func (Measurement) Number ¶
func (m Measurement) Number() number.Number
Number returns a number recorded in this measurement.
func (Measurement) SyncImpl ¶
func (m Measurement) SyncImpl() SyncImpl
SyncImpl returns the instrument that created this measurement. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Meter ¶
type Meter struct {
// contains filtered or unexported fields
}
Meter is the creator of metric instruments.
An uninitialized Meter is a no-op implementation.
func WrapMeterImpl ¶
func WrapMeterImpl(impl MeterImpl, instrumentationName string, opts ...MeterOption) Meter
WrapMeterImpl constructs a `Meter` implementation from a `MeterImpl` implementation.
func (Meter) NewBatchObserver ¶
func (m Meter) NewBatchObserver(callback BatchObserverFunc) BatchObserver
NewBatchObserver creates a new BatchObserver that supports making batches of observations for multiple instruments.
func (Meter) NewFloat64Counter ¶
func (m Meter) NewFloat64Counter(name string, options ...InstrumentOption) (Float64Counter, error)
NewFloat64Counter creates a new floating point Counter with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewFloat64CounterObserver ¶ added in v0.23.0
func (m Meter) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64CounterObserver, error)
NewFloat64CounterObserver creates a new floating point CounterObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewFloat64GaugeObserver ¶ added in v0.23.0
func (m Meter) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64GaugeObserver, error)
NewFloat64GaugeObserver creates a new floating point GaugeObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewFloat64Histogram ¶ added in v0.23.0
func (m Meter) NewFloat64Histogram(name string, opts ...InstrumentOption) (Float64Histogram, error)
NewFloat64Histogram creates a new floating point Histogram with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewFloat64UpDownCounter ¶
func (m Meter) NewFloat64UpDownCounter(name string, options ...InstrumentOption) (Float64UpDownCounter, error)
NewFloat64UpDownCounter creates a new floating point UpDownCounter with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewFloat64UpDownCounterObserver ¶ added in v0.23.0
func (m Meter) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownCounterObserver, error)
NewFloat64UpDownCounterObserver creates a new floating point UpDownCounterObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64Counter ¶
func (m Meter) NewInt64Counter(name string, options ...InstrumentOption) (Int64Counter, error)
NewInt64Counter creates a new integer Counter instrument with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64CounterObserver ¶ added in v0.23.0
func (m Meter) NewInt64CounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64CounterObserver, error)
NewInt64CounterObserver creates a new integer CounterObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64GaugeObserver ¶ added in v0.23.0
func (m Meter) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64GaugeObserver, error)
NewInt64GaugeObserver creates a new integer GaugeObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64Histogram ¶ added in v0.23.0
func (m Meter) NewInt64Histogram(name string, opts ...InstrumentOption) (Int64Histogram, error)
NewInt64Histogram creates a new integer Histogram instrument with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64UpDownCounter ¶
func (m Meter) NewInt64UpDownCounter(name string, options ...InstrumentOption) (Int64UpDownCounter, error)
NewInt64UpDownCounter creates a new integer UpDownCounter instrument with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) NewInt64UpDownCounterObserver ¶ added in v0.23.0
func (m Meter) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownCounterObserver, error)
NewInt64UpDownCounterObserver creates a new integer UpDownCounterObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).
func (Meter) RecordBatch ¶
RecordBatch atomically records a batch of measurements.
type MeterConfig ¶
type MeterConfig struct {
// contains filtered or unexported fields
}
MeterConfig contains options for Meters.
func NewMeterConfig ¶
func NewMeterConfig(opts ...MeterOption) MeterConfig
NewMeterConfig creates a new MeterConfig and applies all the given options.
func (MeterConfig) InstrumentationVersion ¶
func (cfg MeterConfig) InstrumentationVersion() string
InstrumentationVersion is the version of the library providing instrumentation.
type MeterImpl ¶
type MeterImpl interface { // RecordBatch atomically records a batch of measurements. RecordBatch(ctx context.Context, labels []attribute.KeyValue, measurement ...Measurement) // NewSyncInstrument returns a newly constructed // synchronous instrument implementation or an error, should // one occur. NewSyncInstrument(descriptor Descriptor) (SyncImpl, error) // NewAsyncInstrument returns a newly constructed // asynchronous instrument implementation or an error, should // one occur. NewAsyncInstrument( descriptor Descriptor, runner AsyncRunner, ) (AsyncImpl, error) }
MeterImpl is the interface an SDK must implement to supply a Meter implementation.
type MeterMust ¶
type MeterMust struct {
// contains filtered or unexported fields
}
MeterMust is a wrapper for Meter interfaces that panics when any instrument constructor encounters an error.
func Must ¶
Must constructs a MeterMust implementation from a Meter, allowing the application to panic when any instrument constructor yields an error.
func (MeterMust) NewBatchObserver ¶
func (mm MeterMust) NewBatchObserver(callback BatchObserverFunc) BatchObserverMust
NewBatchObserver returns a wrapper around BatchObserver that panics when any instrument constructor returns an error.
func (MeterMust) NewFloat64Counter ¶
func (mm MeterMust) NewFloat64Counter(name string, cos ...InstrumentOption) Float64Counter
NewFloat64Counter calls `Meter.NewFloat64Counter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64CounterObserver ¶ added in v0.23.0
func (mm MeterMust) NewFloat64CounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64CounterObserver
NewFloat64CounterObserver calls `Meter.NewFloat64CounterObserver` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64GaugeObserver ¶ added in v0.23.0
func (mm MeterMust) NewFloat64GaugeObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64GaugeObserver
NewFloat64GaugeObserver calls `Meter.NewFloat64GaugeObserver` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64Histogram ¶ added in v0.23.0
func (mm MeterMust) NewFloat64Histogram(name string, mos ...InstrumentOption) Float64Histogram
NewFloat64Histogram calls `Meter.NewFloat64Histogram` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64UpDownCounter ¶
func (mm MeterMust) NewFloat64UpDownCounter(name string, cos ...InstrumentOption) Float64UpDownCounter
NewFloat64UpDownCounter calls `Meter.NewFloat64UpDownCounter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64UpDownCounterObserver ¶ added in v0.23.0
func (mm MeterMust) NewFloat64UpDownCounterObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownCounterObserver
NewFloat64UpDownCounterObserver calls `Meter.NewFloat64UpDownCounterObserver` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64Counter ¶
func (mm MeterMust) NewInt64Counter(name string, cos ...InstrumentOption) Int64Counter
NewInt64Counter calls `Meter.NewInt64Counter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64CounterObserver ¶ added in v0.23.0
func (mm MeterMust) NewInt64CounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64CounterObserver
NewInt64CounterObserver calls `Meter.NewInt64CounterObserver` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64GaugeObserver ¶ added in v0.23.0
func (mm MeterMust) NewInt64GaugeObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64GaugeObserver
NewInt64GaugeObserver calls `Meter.NewInt64GaugeObserver` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64Histogram ¶ added in v0.23.0
func (mm MeterMust) NewInt64Histogram(name string, mos ...InstrumentOption) Int64Histogram
NewInt64Histogram calls `Meter.NewInt64Histogram` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64UpDownCounter ¶
func (mm MeterMust) NewInt64UpDownCounter(name string, cos ...InstrumentOption) Int64UpDownCounter
NewInt64UpDownCounter calls `Meter.NewInt64UpDownCounter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64UpDownCounterObserver ¶ added in v0.23.0
func (mm MeterMust) NewInt64UpDownCounterObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownCounterObserver
NewInt64UpDownCounterObserver calls `Meter.NewInt64UpDownCounterObserver` and returns the instrument, panicking if it encounters an error.
type MeterOption ¶
type MeterOption interface {
// contains filtered or unexported methods
}
MeterOption is an interface for applying Meter options.
type MeterProvider ¶
type MeterProvider interface { // Meter creates an implementation of the Meter interface. // The instrumentationName must be the name of the library providing // instrumentation. This name may be the same as the instrumented code // only if that code provides built-in instrumentation. If the // instrumentationName is empty, then a implementation defined default // name will be used instead. Meter(instrumentationName string, opts ...MeterOption) Meter }
MeterProvider supports named Meter instances.
type NoopAsync ¶
type NoopAsync struct {
// contains filtered or unexported fields
}
func (NoopAsync) Descriptor ¶
func (NoopAsync) Descriptor() Descriptor
func (NoopAsync) Implementation ¶
func (NoopAsync) Implementation() interface{}
type NoopMeterProvider ¶
type NoopMeterProvider struct{}
func (NoopMeterProvider) Meter ¶
func (NoopMeterProvider) Meter(_ string, _ ...MeterOption) Meter
type NoopSync ¶
type NoopSync struct {
// contains filtered or unexported fields
}
func (NoopSync) Descriptor ¶
func (NoopSync) Descriptor() Descriptor
func (NoopSync) Implementation ¶
func (NoopSync) Implementation() interface{}
type Observation ¶
type Observation struct {
// contains filtered or unexported fields
}
Observation is used for reporting an asynchronous batch of metric values. Instances of this type should be created by asynchronous instruments (e.g., Int64GaugeObserver.Observation()).
func (Observation) AsyncImpl ¶
func (m Observation) AsyncImpl() AsyncImpl
AsyncImpl returns the instrument that created this observation. This returns an implementation-level object for use by the SDK, users should not refer to this.
func (Observation) Number ¶
func (m Observation) Number() number.Number
Number returns a number recorded in this observation.
type SyncImpl ¶
type SyncImpl interface { InstrumentImpl // Bind creates an implementation-level bound instrument, // binding a label set with this instrument implementation. Bind(labels []attribute.KeyValue) BoundSyncImpl // RecordOne captures a single synchronous metric event. RecordOne(ctx context.Context, number number.Number, labels []attribute.KeyValue) }
SyncImpl is the implementation-level interface to a generic synchronous instrument (e.g., Histogram and Counter instruments).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package number provides a number abstraction for instruments that either support int64 or float64 input values.
|
Package number provides a number abstraction for instruments that either support int64 or float64 input values. |
Package registry provides a non-standalone implementation of MeterProvider that adds uniqueness checking for instrument descriptors on top of other MeterProvider it wraps.
|
Package registry provides a non-standalone implementation of MeterProvider that adds uniqueness checking for instrument descriptors on top of other MeterProvider it wraps. |
Package unit provides units.
|
Package unit provides units. |