Documentation ¶
Overview ¶
metric package provides an API for reporting diagnostic measurements using four basic kinds of instruments.
The three basic kinds are:
- counters - measures - observers
All instruments report either float64 or int64 values.
The primary object that handles metrics is Meter. Meter can be obtained from Provider. The implementations of the Meter and Provider are provided by SDK. Normally, the Meter is used directly only for the instrument creation and batch recording.
Counters are instruments that are reporting a quantity or a sum. An example could be bank account balance or bytes downloaded. Counters can be created with either NewFloat64Counter or NewInt64Counter. Counters expect non-negative values by default to be reported. This can be changed with the WithMonotonic option (passing false as a parameter) passed to the Meter.New*Counter function - this allows reporting negative values. To report the new value, use an Add function.
Measures are instruments that are reporting values that are recorded separately to figure out some statistical properties from those values (like average). An example could be temperature over time or lines of code in the project over time. Measures can be created with either NewFloat64Measure or NewInt64Measure. Measures by default take only non-negative values. This can be changed with the WithAbsolute option (passing false as a parameter) passed to the New*Measure function - this allows reporting negative values too. To report a new value, use the Record function.
Observers are instruments that are reporting a current state of a set of values. An example could be voltage or temperature. Observers can be created with either RegisterFloat64Observer or RegisterInt64Observer. Observers by default have no limitations about reported values - they can be less or greater than the last reported value. This can be changed with the WithMonotonic option passed to the Register*Observer function - this permits the reported values only to go up. Reporting of the new values happens asynchronously, with the use of a callback passed to the Register*Observer function. The callback can report multiple values. There is no unregister function.
Counters and measures support creating bound instruments for a potentially more efficient reporting. The bound instruments have the same function names as the instruments (so a Counter bound instrument has Add, and a Measure bound instrument has Record). Bound Instruments can be created with the Bind function of the respective instrument. When done with the bound instrument, call Unbind on it.
Index ¶
- Variables
- type AsyncBatchRunner
- type AsyncImpl
- type AsyncRunner
- type AsyncSingleRunner
- type BatchObserver
- type BatchObserverCallback
- type BatchObserverMust
- type BatchObserverResult
- type BoundFloat64Counter
- type BoundFloat64Measure
- type BoundInt64Counter
- type BoundInt64Measure
- type BoundSyncImpl
- type Config
- type Descriptor
- type Float64Counter
- type Float64Measure
- type Float64Observer
- type Float64ObserverCallback
- type Float64ObserverResult
- type InstrumentImpl
- type Int64Counter
- type Int64Measure
- type Int64Observer
- type Int64ObserverCallback
- type Int64ObserverResult
- type Kind
- type Measurement
- type Meter
- func (m Meter) MeterImpl() MeterImpl
- func (m Meter) NewBatchObserver(callback BatchObserverCallback) BatchObserver
- func (m Meter) NewFloat64Counter(name string, options ...Option) (Float64Counter, error)
- func (m Meter) NewFloat64Measure(name string, opts ...Option) (Float64Measure, error)
- func (m Meter) NewInt64Counter(name string, options ...Option) (Int64Counter, error)
- func (m Meter) NewInt64Measure(name string, opts ...Option) (Int64Measure, error)
- func (m Meter) RecordBatch(ctx context.Context, ls []kv.KeyValue, ms ...Measurement)
- func (m Meter) RegisterFloat64Observer(name string, callback Float64ObserverCallback, opts ...Option) (Float64Observer, error)
- func (m Meter) RegisterInt64Observer(name string, callback Int64ObserverCallback, opts ...Option) (Int64Observer, error)
- type MeterImpl
- type MeterMust
- func (mm MeterMust) NewBatchObserver(callback BatchObserverCallback) BatchObserverMust
- func (mm MeterMust) NewFloat64Counter(name string, cos ...Option) Float64Counter
- func (mm MeterMust) NewFloat64Measure(name string, mos ...Option) Float64Measure
- func (mm MeterMust) NewInt64Counter(name string, cos ...Option) Int64Counter
- func (mm MeterMust) NewInt64Measure(name string, mos ...Option) Int64Measure
- func (mm MeterMust) RegisterFloat64Observer(name string, callback Float64ObserverCallback, oos ...Option) Float64Observer
- func (mm MeterMust) RegisterInt64Observer(name string, callback Int64ObserverCallback, oos ...Option) Int64Observer
- type NoopAsync
- type NoopProvider
- type NoopSync
- type Number
- func (n *Number) AddFloat64(f float64)
- func (n *Number) AddFloat64Atomic(f float64)
- func (n *Number) AddInt64(i int64)
- func (n *Number) AddInt64Atomic(i int64)
- func (n *Number) AddNumber(kind NumberKind, nn Number)
- func (n *Number) AddNumberAtomic(kind NumberKind, nn Number)
- func (n *Number) AddRaw(kind NumberKind, r uint64)
- func (n *Number) AddRawAtomic(kind NumberKind, r uint64)
- func (n *Number) AddUint64(u uint64)
- func (n *Number) AddUint64Atomic(u uint64)
- func (n *Number) AsFloat64() float64
- func (n *Number) AsFloat64Atomic() float64
- func (n *Number) AsFloat64Ptr() *float64
- func (n *Number) AsInt64() int64
- func (n *Number) AsInt64Atomic() int64
- func (n *Number) AsInt64Ptr() *int64
- func (n *Number) AsInterface(kind NumberKind) interface{}
- func (n *Number) AsNumber() Number
- func (n *Number) AsNumberAtomic() Number
- func (n *Number) AsRaw() uint64
- func (n *Number) AsRawAtomic() uint64
- func (n *Number) AsRawPtr() *uint64
- func (n *Number) AsUint64() uint64
- func (n *Number) AsUint64Atomic() uint64
- func (n *Number) AsUint64Ptr() *uint64
- func (n *Number) CoerceToFloat64(kind NumberKind) float64
- func (n *Number) CoerceToInt64(kind NumberKind) int64
- func (n *Number) CoerceToUint64(kind NumberKind) uint64
- func (n *Number) CompareAndSwapFloat64(of, nf float64) bool
- func (n *Number) CompareAndSwapInt64(oi, ni int64) bool
- func (n *Number) CompareAndSwapNumber(on, nn Number) bool
- func (n *Number) CompareAndSwapRaw(or, nr uint64) bool
- func (n *Number) CompareAndSwapUint64(ou, nu uint64) bool
- func (n *Number) CompareFloat64(f float64) int
- func (n *Number) CompareInt64(i int64) int
- func (n *Number) CompareNumber(kind NumberKind, nn Number) int
- func (n *Number) CompareRaw(kind NumberKind, r uint64) int
- func (n *Number) CompareUint64(u uint64) int
- func (n *Number) Emit(kind NumberKind) string
- func (n *Number) IsNegative(kind NumberKind) bool
- func (n *Number) IsPositive(kind NumberKind) bool
- func (n *Number) IsZero(kind NumberKind) bool
- func (n *Number) SetFloat64(f float64)
- func (n *Number) SetFloat64Atomic(f float64)
- func (n *Number) SetInt64(i int64)
- func (n *Number) SetInt64Atomic(i int64)
- func (n *Number) SetNumber(nn Number)
- func (n *Number) SetNumberAtomic(nn Number)
- func (n *Number) SetRaw(r uint64)
- func (n *Number) SetRawAtomic(r uint64)
- func (n *Number) SetUint64(u uint64)
- func (n *Number) SetUint64Atomic(u uint64)
- func (n *Number) SwapFloat64(f float64) float64
- func (n *Number) SwapFloat64Atomic(f float64) float64
- func (n *Number) SwapInt64(i int64) int64
- func (n *Number) SwapInt64Atomic(i int64) int64
- func (n *Number) SwapNumber(nn Number) Number
- func (n *Number) SwapNumberAtomic(nn Number) Number
- func (n *Number) SwapRaw(r uint64) uint64
- func (n *Number) SwapRawAtomic(r uint64) uint64
- func (n *Number) SwapUint64(u uint64) uint64
- func (n *Number) SwapUint64Atomic(u uint64) uint64
- type NumberKind
- type Observation
- type Option
- type Provider
- type SyncImpl
Constants ¶
This section is empty.
Variables ¶
var ErrSDKReturnedNilImpl = errors.New("SDK returned a nil implementation")
Functions ¶
This section is empty.
Types ¶
type AsyncBatchRunner ¶ added in v0.5.0
type AsyncBatchRunner interface { // Run accepts a function for capturing observations of // multiple instruments. Run(capture func([]kv.KeyValue, ...Observation)) AsyncRunner }
AsyncBatchRunner is an interface implemented by batch-observer callbacks.
type AsyncImpl ¶ added in v0.3.0
type AsyncImpl interface { InstrumentImpl }
AsyncImpl is an implementation-level interface to an asynchronous instrument (e.g., Observer instruments).
type AsyncRunner ¶ added in v0.5.0
type AsyncRunner interface {
// contains filtered or unexported methods
}
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 ¶ added in v0.5.0
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(single AsyncImpl, capture func([]kv.KeyValue, ...Observation)) AsyncRunner }
AsyncSingleRunner is an interface implemented by single-observer callbacks.
type BatchObserver ¶ added in v0.5.0
type BatchObserver struct {
// contains filtered or unexported fields
}
BatchObserver represents an Observer callback that can report observations for multiple instruments.
func (BatchObserver) RegisterFloat64Observer ¶ added in v0.5.0
func (b BatchObserver) RegisterFloat64Observer(name string, opts ...Option) (Float64Observer, error)
RegisterFloat64Observer creates a new floating point Observer 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) RegisterInt64Observer ¶ added in v0.5.0
func (b BatchObserver) RegisterInt64Observer(name string, opts ...Option) (Int64Observer, error)
RegisterInt64Observer creates a new integer Observer 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 BatchObserverCallback ¶ added in v0.5.0
type BatchObserverCallback func(BatchObserverResult)
BatchObserverCallback is a callback argument for use with any Observer instrument that will be reported as a batch of observations.
func (*BatchObserverCallback) Run ¶ added in v0.5.0
func (b *BatchObserverCallback) Run(function func([]kv.KeyValue, ...Observation))
Run implements AsyncBatchRunner.
type BatchObserverMust ¶ added in v0.5.0
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) RegisterFloat64Observer ¶ added in v0.5.0
func (bm BatchObserverMust) RegisterFloat64Observer(name string, oos ...Option) Float64Observer
RegisterFloat64Observer calls `BatchObserver.RegisterFloat64Observer` and returns the instrument, panicking if it encounters an error.
func (BatchObserverMust) RegisterInt64Observer ¶ added in v0.5.0
func (bm BatchObserverMust) RegisterInt64Observer(name string, oos ...Option) Int64Observer
RegisterInt64Observer calls `BatchObserver.RegisterInt64Observer` and returns the instrument, panicking if it encounters an error.
type BatchObserverResult ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (br BatchObserverResult) Observe(labels []kv.KeyValue, obs ...Observation)
Observe captures a multiple observations from the associated batch instrument callback, with the given labels.
type BoundFloat64Counter ¶ added in v0.2.1
type BoundFloat64Counter struct {
// contains filtered or unexported fields
}
BoundFloat64Counter is a bound instrument for Float64Counter.
It inherits the Unbind function from syncBoundInstrument.
type BoundFloat64Measure ¶ added in v0.2.1
type BoundFloat64Measure struct {
// contains filtered or unexported fields
}
BoundFloat64Measure is a bound instrument for Float64Measure.
It inherits the Unbind function from syncBoundInstrument.
type BoundInt64Counter ¶ added in v0.2.1
type BoundInt64Counter struct {
// contains filtered or unexported fields
}
BoundInt64Counter is a boundInstrument for Int64Counter.
It inherits the Unbind function from syncBoundInstrument.
type BoundInt64Measure ¶ added in v0.2.1
type BoundInt64Measure struct {
// contains filtered or unexported fields
}
BoundInt64Measure is a bound instrument for Int64Measure.
It inherits the Unbind function from syncBoundInstrument.
type BoundSyncImpl ¶ added in v0.3.0
type BoundSyncImpl interface { // RecordOne captures a single synchronous metric event. RecordOne(ctx context.Context, number Number) // Unbind frees the resources associated with this bound instrument. It // does not affect the metric this bound instrument was created through. Unbind() }
BoundSyncImpl is the implementation-level interface to a generic bound synchronous instrument
type Config ¶ added in v0.3.0
type Config struct { // Description is an optional field describing the metric // instrument. Description string // Unit is an optional field describing the metric instrument. Unit unit.Unit // LibraryName is the name given to the Meter that created // this instrument. See `Provider`. LibraryName string }
Config contains some options for metrics of any kind.
type Descriptor ¶ added in v0.3.0
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 ¶ added in v0.3.0
func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...Option) Descriptor
NewDescriptor returns a Descriptor with the given contents.
func (Descriptor) Description ¶ added in v0.3.0
func (d Descriptor) Description() string
Description provides a human-readable description of the metric instrument.
func (Descriptor) LibraryName ¶ added in v0.4.0
func (d Descriptor) LibraryName() string
LibraryName returns the metric instrument's library name, typically given via a call to Provider.Meter().
func (Descriptor) MetricKind ¶ added in v0.3.0
func (d Descriptor) MetricKind() Kind
MetricKind returns the specific kind of instrument.
func (Descriptor) Name ¶ added in v0.3.0
func (d Descriptor) Name() string
Name returns the metric instrument's name.
func (Descriptor) NumberKind ¶ added in v0.3.0
func (d Descriptor) NumberKind() NumberKind
NumberKind returns whether this instrument is declared over int64, float64, or uint64 values.
func (Descriptor) Unit ¶ added in v0.3.0
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 ¶ added in v0.2.1
func (c Float64Counter) Bind(labels ...kv.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 Float64Measure ¶
type Float64Measure struct {
// contains filtered or unexported fields
}
Float64Measure is a metric that records float64 values.
func (Float64Measure) Bind ¶ added in v0.2.1
func (c Float64Measure) Bind(labels ...kv.KeyValue) (h BoundFloat64Measure)
Bind creates a bound instrument for this measure. The labels are associated with values recorded via subsequent calls to Record.
func (Float64Measure) Measurement ¶
func (c Float64Measure) Measurement(value float64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Float64Observer ¶ added in v0.3.0
type Float64Observer struct {
// contains filtered or unexported fields
}
Float64Observer is a metric that captures a set of float64 values at a point in time.
func (Float64Observer) Observation ¶ added in v0.5.0
func (f Float64Observer) Observation(v float64) Observation
Observation returns an Observation, a BatchObserverCallback argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Float64ObserverCallback ¶ added in v0.3.0
type Float64ObserverCallback func(Float64ObserverResult)
Float64ObserverCallback is a type of callback that floating point observers run.
func (*Float64ObserverCallback) Run ¶ added in v0.5.0
func (f *Float64ObserverCallback) Run(impl AsyncImpl, function func([]kv.KeyValue, ...Observation))
Run implements AsyncSingleRunner.
type Float64ObserverResult ¶ added in v0.3.0
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 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 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 ¶ added in v0.2.1
func (c Int64Counter) Bind(labels ...kv.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 Int64Measure ¶
type Int64Measure struct {
// contains filtered or unexported fields
}
Int64Measure is a metric that records int64 values.
func (Int64Measure) Bind ¶ added in v0.2.1
func (c Int64Measure) Bind(labels ...kv.KeyValue) (h BoundInt64Measure)
Bind creates a bound instrument for this measure. The labels are associated with values recorded via subsequent calls to Record.
func (Int64Measure) Measurement ¶
func (c Int64Measure) Measurement(value int64) Measurement
Measurement creates a Measurement object to use with batch recording.
type Int64Observer ¶ added in v0.3.0
type Int64Observer struct {
// contains filtered or unexported fields
}
Int64Observer is a metric that captures a set of int64 values at a point in time.
func (Int64Observer) Observation ¶ added in v0.5.0
func (i Int64Observer) Observation(v int64) Observation
Observation returns an Observation, a BatchObserverCallback argument, for an asynchronous integer instrument. This returns an implementation-level object for use by the SDK, users should not refer to this.
type Int64ObserverCallback ¶ added in v0.3.0
type Int64ObserverCallback func(Int64ObserverResult)
Int64ObserverCallback is a type of callback that integral observers run.
func (*Int64ObserverCallback) Run ¶ added in v0.5.0
func (i *Int64ObserverCallback) Run(impl AsyncImpl, function func([]kv.KeyValue, ...Observation))
Run implements AsyncSingleRunner.
type Int64ObserverResult ¶ added in v0.3.0
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 Measurement ¶
type Measurement struct {
// contains filtered or unexported fields
}
Measurement is used for reporting a batch of metric values. Instances of this type should be created by instruments (e.g., Int64Counter.Measurement()).
func (Measurement) Number ¶
func (m Measurement) Number() Number
Number returns a number recorded in this measurement.
func (Measurement) SyncImpl ¶ added in v0.3.0
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 OpenTelemetry metric API, based on a `MeterImpl` implementation and the `Meter` library name.
An uninitialized Meter is a no-op implementation.
func WrapMeterImpl ¶ added in v0.3.0
WrapMeterImpl constructs a `Meter` implementation from a `MeterImpl` implementation.
func (Meter) NewBatchObserver ¶ added in v0.5.0
func (m Meter) NewBatchObserver(callback BatchObserverCallback) 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 ...Option) (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) NewFloat64Measure ¶
func (m Meter) NewFloat64Measure(name string, opts ...Option) (Float64Measure, error)
NewFloat64Measure creates a new floating point Measure 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) NewInt64Counter ¶
func (m Meter) NewInt64Counter(name string, options ...Option) (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) NewInt64Measure ¶
func (m Meter) NewInt64Measure(name string, opts ...Option) (Int64Measure, error)
NewInt64Measure creates a new integer Measure 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) RecordBatch ¶
RecordBatch atomically records a batch of measurements.
func (Meter) RegisterFloat64Observer ¶ added in v0.3.0
func (m Meter) RegisterFloat64Observer(name string, callback Float64ObserverCallback, opts ...Option) (Float64Observer, error)
RegisterFloat64Observer creates a new floating point Observer 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) RegisterInt64Observer ¶ added in v0.3.0
func (m Meter) RegisterInt64Observer(name string, callback Int64ObserverCallback, opts ...Option) (Int64Observer, error)
RegisterInt64Observer creates a new integer Observer 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).
type MeterImpl ¶ added in v0.3.0
type MeterImpl interface { // RecordBatch atomically records a batch of measurements. RecordBatch(context.Context, []kv.KeyValue, ...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 ¶ added in v0.3.0
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 ¶ added in v0.3.0
Must constructs a MeterMust implementation from a Meter, allowing the application to panic when any instrument constructor yields an error.
func (MeterMust) NewBatchObserver ¶ added in v0.5.0
func (mm MeterMust) NewBatchObserver(callback BatchObserverCallback) BatchObserverMust
NewBatchObserver returns a wrapper around BatchObserver that panics when any instrument constructor returns an error.
func (MeterMust) NewFloat64Counter ¶ added in v0.3.0
func (mm MeterMust) NewFloat64Counter(name string, cos ...Option) Float64Counter
NewFloat64Counter calls `Meter.NewFloat64Counter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewFloat64Measure ¶ added in v0.3.0
func (mm MeterMust) NewFloat64Measure(name string, mos ...Option) Float64Measure
NewFloat64Measure calls `Meter.NewFloat64Measure` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64Counter ¶ added in v0.3.0
func (mm MeterMust) NewInt64Counter(name string, cos ...Option) Int64Counter
NewInt64Counter calls `Meter.NewInt64Counter` and returns the instrument, panicking if it encounters an error.
func (MeterMust) NewInt64Measure ¶ added in v0.3.0
func (mm MeterMust) NewInt64Measure(name string, mos ...Option) Int64Measure
NewInt64Measure calls `Meter.NewInt64Measure` and returns the instrument, panicking if it encounters an error.
func (MeterMust) RegisterFloat64Observer ¶ added in v0.3.0
func (mm MeterMust) RegisterFloat64Observer(name string, callback Float64ObserverCallback, oos ...Option) Float64Observer
RegisterFloat64Observer calls `Meter.RegisterFloat64Observer` and returns the instrument, panicking if it encounters an error.
func (MeterMust) RegisterInt64Observer ¶ added in v0.3.0
func (mm MeterMust) RegisterInt64Observer(name string, callback Int64ObserverCallback, oos ...Option) Int64Observer
RegisterInt64Observer calls `Meter.RegisterInt64Observer` and returns the instrument, panicking if it encounters an error.
type NoopAsync ¶ added in v0.3.0
type NoopAsync struct {
// contains filtered or unexported fields
}
func (NoopAsync) Descriptor ¶ added in v0.3.0
func (NoopAsync) Descriptor() Descriptor
func (NoopAsync) Implementation ¶ added in v0.3.0
func (NoopAsync) Implementation() interface{}
type NoopProvider ¶
type NoopProvider struct{}
func (NoopProvider) Meter ¶ added in v0.2.0
func (NoopProvider) Meter(name string) Meter
type NoopSync ¶ added in v0.3.0
type NoopSync struct {
// contains filtered or unexported fields
}
func (NoopSync) Descriptor ¶ added in v0.3.0
func (NoopSync) Descriptor() Descriptor
func (NoopSync) Implementation ¶ added in v0.3.0
func (NoopSync) Implementation() interface{}
type Number ¶ added in v0.5.0
type Number uint64
Number represents either an integral or a floating point value. It needs to be accompanied with a source of NumberKind that describes the actual type of the value stored within Number.
func NewFloat64Number ¶ added in v0.5.0
NewFloat64Number creates a floating point Number.
func NewInt64Number ¶ added in v0.5.0
NewInt64Number creates an integral Number.
func NewNumberFromRaw ¶ added in v0.5.0
NewNumberFromRaw creates a new Number from a raw value.
func NewUint64Number ¶ added in v0.5.0
NewInt64Number creates an integral Number.
func (*Number) AddFloat64 ¶ added in v0.5.0
AddFloat64 assumes that the number contains a float64 and adds the passed float64 to it.
func (*Number) AddFloat64Atomic ¶ added in v0.5.0
AddFloat64Atomic assumes that the number contains a float64 and adds the passed float64 to it atomically.
func (*Number) AddInt64 ¶ added in v0.5.0
AddInt64 assumes that the number contains an int64 and adds the passed int64 to it.
func (*Number) AddInt64Atomic ¶ added in v0.5.0
AddInt64Atomic assumes that the number contains an int64 and adds the passed int64 to it atomically.
func (*Number) AddNumber ¶ added in v0.5.0
func (n *Number) AddNumber(kind NumberKind, nn Number)
AddNumber assumes that this and the passed number are of the passed kind and adds the passed number to this number.
func (*Number) AddNumberAtomic ¶ added in v0.5.0
func (n *Number) AddNumberAtomic(kind NumberKind, nn Number)
AddNumberAtomic assumes that this and the passed number are of the passed kind and adds the passed number to this number atomically.
func (*Number) AddRaw ¶ added in v0.5.0
func (n *Number) AddRaw(kind NumberKind, r uint64)
AddRaw assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number.
func (*Number) AddRawAtomic ¶ added in v0.5.0
func (n *Number) AddRawAtomic(kind NumberKind, r uint64)
AddRawAtomic assumes that this number and the passed raw value are of the passed kind and adds the passed raw value to this number atomically.
func (*Number) AddUint64 ¶ added in v0.5.0
AddUint64 assumes that the number contains a uint64 and adds the passed uint64 to it.
func (*Number) AddUint64Atomic ¶ added in v0.5.0
AddUint64Atomic assumes that the number contains a uint64 and atomically adds the passed uint64 to it.
func (*Number) AsFloat64 ¶ added in v0.5.0
AsFloat64 assumes that the measurement value contains a float64 and returns it as such.
func (*Number) AsFloat64Atomic ¶ added in v0.5.0
AsFloat64Atomic assumes that the measurement value contains a float64 and returns it as such atomically.
func (*Number) AsFloat64Ptr ¶ added in v0.5.0
AsFloat64Ptr assumes that the number contains a float64 and returns a pointer to it.
func (*Number) AsInt64 ¶ added in v0.5.0
AsInt64 assumes that the value contains an int64 and returns it as such.
func (*Number) AsInt64Atomic ¶ added in v0.5.0
AsInt64Atomic assumes that the number contains an int64 and returns it as such atomically.
func (*Number) AsInt64Ptr ¶ added in v0.5.0
AsInt64Ptr assumes that the number contains an int64 and returns a pointer to it.
func (*Number) AsInterface ¶ added in v0.5.0
func (n *Number) AsInterface(kind NumberKind) interface{}
AsInterface returns the number as an interface{}, typically used for NumberKind-correct JSON conversion.
func (*Number) AsNumberAtomic ¶ added in v0.5.0
AsNumberAtomic gets the Number atomically.
func (*Number) AsRaw ¶ added in v0.5.0
AsRaw gets the uninterpreted raw value. Might be useful for some atomic operations.
func (*Number) AsRawAtomic ¶ added in v0.5.0
AsRawAtomic gets the uninterpreted raw value atomically. Might be useful for some atomic operations.
func (*Number) AsRawPtr ¶ added in v0.5.0
AsRawPtr gets the pointer to the raw, uninterpreted raw value. Might be useful for some atomic operations.
func (*Number) AsUint64 ¶ added in v0.5.0
AsUint64 assumes that the value contains an uint64 and returns it as such.
func (*Number) AsUint64Atomic ¶ added in v0.5.0
AsUint64Atomic assumes that the number contains a uint64 and returns it as such atomically.
func (*Number) AsUint64Ptr ¶ added in v0.5.0
AsUint64Ptr assumes that the number contains a uint64 and returns a pointer to it.
func (*Number) CoerceToFloat64 ¶ added in v0.5.0
func (n *Number) CoerceToFloat64(kind NumberKind) float64
CoerceToFloat64 casts the number to float64. May result in data/precision loss.
func (*Number) CoerceToInt64 ¶ added in v0.5.0
func (n *Number) CoerceToInt64(kind NumberKind) int64
CoerceToInt64 casts the number to int64. May result in data/precision loss.
func (*Number) CoerceToUint64 ¶ added in v0.5.0
func (n *Number) CoerceToUint64(kind NumberKind) uint64
CoerceToUint64 casts the number to uint64. May result in data/precision loss.
func (*Number) CompareAndSwapFloat64 ¶ added in v0.5.0
CompareAndSwapFloat64 assumes that this number contains a float64 and does the atomic CAS operation on it.
func (*Number) CompareAndSwapInt64 ¶ added in v0.5.0
CompareAndSwapInt64 assumes that this number contains an int64 and does the atomic CAS operation on it.
func (*Number) CompareAndSwapNumber ¶ added in v0.5.0
CompareAndSwapNumber does the atomic CAS operation on this number. This number and passed old and new numbers should be of the same kind.
func (*Number) CompareAndSwapRaw ¶ added in v0.5.0
CompareAndSwapRaw does the atomic CAS operation on this number. This number and passed old and new raw values should be of the same kind.
func (*Number) CompareAndSwapUint64 ¶ added in v0.5.0
CompareAndSwapUint64 assumes that this number contains a uint64 and does the atomic CAS operation on it.
func (*Number) CompareFloat64 ¶ added in v0.5.0
CompareFloat64 assumes that the Number contains a float64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.
Do not compare NaN values.
func (*Number) CompareInt64 ¶ added in v0.5.0
CompareInt64 assumes that the Number contains an int64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.
func (*Number) CompareNumber ¶ added in v0.5.0
func (n *Number) CompareNumber(kind NumberKind, nn Number) int
CompareNumber compares two Numbers given their kind. Both numbers should have the same kind. This returns:
0 if the numbers are equal -1 if the subject `n` is less than the argument `nn` +1 if the subject `n` is greater than the argument `nn`
func (*Number) CompareRaw ¶ added in v0.5.0
func (n *Number) CompareRaw(kind NumberKind, r uint64) int
CompareRaw compares two numbers, where one is input as a raw uint64, interpreting both values as a `kind` of number.
func (*Number) CompareUint64 ¶ added in v0.5.0
CompareUint64 assumes that the Number contains an uint64 and performs a comparison between the value and the other value. It returns the typical result of the compare function: -1 if the value is less than the other, 0 if both are equal, 1 if the value is greater than the other.
func (*Number) Emit ¶ added in v0.5.0
func (n *Number) Emit(kind NumberKind) string
Emit returns a string representation of the raw value of the Number. A %d is used for integral values, %f for floating point values.
func (*Number) IsNegative ¶ added in v0.5.0
func (n *Number) IsNegative(kind NumberKind) bool
IsNegative returns true if the actual value is less than zero.
func (*Number) IsPositive ¶ added in v0.5.0
func (n *Number) IsPositive(kind NumberKind) bool
IsPositive returns true if the actual value is greater than zero.
func (*Number) IsZero ¶ added in v0.5.0
func (n *Number) IsZero(kind NumberKind) bool
IsZero returns true if the actual value is equal to zero.
func (*Number) SetFloat64 ¶ added in v0.5.0
SetFloat64 assumes that the number contains a float64 and sets it to the passed value.
func (*Number) SetFloat64Atomic ¶ added in v0.5.0
SetFloat64Atomic assumes that the number contains a float64 and sets it to the passed value atomically.
func (*Number) SetInt64 ¶ added in v0.5.0
SetInt64 assumes that the number contains an int64 and sets it to the passed value.
func (*Number) SetInt64Atomic ¶ added in v0.5.0
SetInt64Atomic assumes that the number contains an int64 and sets it to the passed value atomically.
func (*Number) SetNumber ¶ added in v0.5.0
SetNumber sets the number to the passed number. Both should be of the same kind.
func (*Number) SetNumberAtomic ¶ added in v0.5.0
SetNumberAtomic sets the number to the passed number atomically. Both should be of the same kind.
func (*Number) SetRaw ¶ added in v0.5.0
SetRaw sets the number to the passed raw value. Both number and the raw number should represent the same kind.
func (*Number) SetRawAtomic ¶ added in v0.5.0
SetRawAtomic sets the number to the passed raw value atomically. Both number and the raw number should represent the same kind.
func (*Number) SetUint64 ¶ added in v0.5.0
SetUint64 assumes that the number contains a uint64 and sets it to the passed value.
func (*Number) SetUint64Atomic ¶ added in v0.5.0
SetUint64Atomic assumes that the number contains a uint64 and sets it to the passed value atomically.
func (*Number) SwapFloat64 ¶ added in v0.5.0
SwapFloat64 assumes that the number contains an float64, sets it to the passed value and returns the old float64 value.
func (*Number) SwapFloat64Atomic ¶ added in v0.5.0
SwapFloat64Atomic assumes that the number contains an float64, sets it to the passed value and returns the old float64 value atomically.
func (*Number) SwapInt64 ¶ added in v0.5.0
SwapInt64 assumes that the number contains an int64, sets it to the passed value and returns the old int64 value.
func (*Number) SwapInt64Atomic ¶ added in v0.5.0
SwapInt64Atomic assumes that the number contains an int64, sets it to the passed value and returns the old int64 value atomically.
func (*Number) SwapNumber ¶ added in v0.5.0
SwapNumber sets the number to the passed number and returns the old number. Both this number and the passed number should be of the same kind.
func (*Number) SwapNumberAtomic ¶ added in v0.5.0
SwapNumberAtomic sets the number to the passed number and returns the old number atomically. Both this number and the passed number should be of the same kind.
func (*Number) SwapRaw ¶ added in v0.5.0
SwapRaw sets the number to the passed raw value and returns the old raw value. Both number and the raw number should represent the same kind.
func (*Number) SwapRawAtomic ¶ added in v0.5.0
SwapRawAtomic sets the number to the passed raw value and returns the old raw value atomically. Both number and the raw number should represent the same kind.
func (*Number) SwapUint64 ¶ added in v0.5.0
SwapUint64 assumes that the number contains an uint64, sets it to the passed value and returns the old uint64 value.
func (*Number) SwapUint64Atomic ¶ added in v0.5.0
SwapUint64Atomic assumes that the number contains an uint64, sets it to the passed value and returns the old uint64 value atomically.
type NumberKind ¶ added in v0.5.0
type NumberKind int8
NumberKind describes the data type of the Number.
const ( // Int64NumberKind means that the Number stores int64. Int64NumberKind NumberKind = iota // Float64NumberKind means that the Number stores float64. Float64NumberKind // Uint64NumberKind means that the Number stores uint64. Uint64NumberKind )
func (NumberKind) Maximum ¶ added in v0.5.0
func (k NumberKind) Maximum() Number
Maximum returns the maximum representable value for a given NumberKind
func (NumberKind) Minimum ¶ added in v0.5.0
func (k NumberKind) Minimum() Number
Minimum returns the minimum representable value for a given NumberKind
func (NumberKind) String ¶ added in v0.5.0
func (i NumberKind) String() string
func (NumberKind) Zero ¶ added in v0.5.0
func (k NumberKind) Zero() Number
Zero returns a zero value for a given NumberKind
type Observation ¶ added in v0.5.0
type Observation struct {
// contains filtered or unexported fields
}
Observation is used for reporting a batch of metric values. Instances of this type should be created by Observer instruments (e.g., Int64Observer.Observation()).
func (Observation) AsyncImpl ¶ added in v0.5.0
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 ¶ added in v0.5.0
func (m Observation) Number() Number
Number returns a number recorded in this observation.
type Option ¶
type Option interface { // Apply is used to set the Option value of a Config. Apply(*Config) }
Option is an interface for applying metric options.
func WithDescription ¶
WithDescription applies provided description.
func WithLibraryName ¶ added in v0.4.0
WithLibraryName applies provided library name. This is meant for use in `Provider` implementations that have not used `WrapMeterImpl`. Implementations built using `WrapMeterImpl` have instrument descriptors taken care of through this package.
This option will have no effect when supplied by the user. Provider implementations are expected to append this option after the user-supplied options when building instrument descriptors.
type Provider ¶
type Provider interface { // Meter gets a named Meter interface. If the name is an // empty string, the provider uses a default name. Meter(name string) Meter }
Provider supports named Meter instances.
type SyncImpl ¶ added in v0.3.0
type SyncImpl interface { InstrumentImpl // Bind creates an implementation-level bound instrument, // binding a label set with this instrument implementation. Bind(labels []kv.KeyValue) BoundSyncImpl // RecordOne captures a single synchronous metric event. RecordOne(ctx context.Context, number Number, labels []kv.KeyValue) }
SyncImpl is the implementation-level interface to a generic synchronous instrument (e.g., Measure and Counter instruments).