metric

package
Version: v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package metric provides support for reporting measurements using instruments.

Instruments are categorized as below:

Synchronous instruments are called by the user with a Context. Asynchronous instruments are called by the SDK during collection.

Additive instruments are semantically intended for capturing a sum. Non-additive instruments are intended for capturing a distribution.

Additive instruments may be monotonic, in which case they are non-descreasing and naturally define a rate.

The synchronous instrument names are:

Counter:           additive, monotonic
UpDownCounter:     additive
ValueRecorder:     non-additive

and the asynchronous instruments are:

SumObserver:       additive, monotonic
UpDownSumObserver: additive
ValueObserver:     non-additive

All instruments are provided with support for either float64 or int64 input values.

The Meter interface supports allocating new instruments as well as interfaces for recording batches of synchronous measurements or asynchronous observations. To obtain a Meter, use a MeterProvider.

The MeterProvider interface supports obtaining a named Meter interface. To obtain a MeterProvider implementation, initialize and configure any compatible SDK.

Index

Constants

This section is empty.

Variables

View Source
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 added in v0.5.0

type AsyncBatchRunner interface {
	// Run accepts a function for capturing observations of
	// multiple instruments.
	Run(ctx context.Context, capture func([]label.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 {
	// 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 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(ctx context.Context, single AsyncImpl, capture func([]label.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) NewFloat64SumObserver added in v0.6.0

func (b BatchObserver) NewFloat64SumObserver(name string, opts ...InstrumentOption) (Float64SumObserver, error)

NewFloat64SumObserver creates a new floating point SumObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (BatchObserver) NewFloat64UpDownSumObserver added in v0.6.0

func (b BatchObserver) NewFloat64UpDownSumObserver(name string, opts ...InstrumentOption) (Float64UpDownSumObserver, error)

NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (BatchObserver) NewFloat64ValueObserver added in v0.6.0

func (b BatchObserver) NewFloat64ValueObserver(name string, opts ...InstrumentOption) (Float64ValueObserver, error)

NewFloat64ValueObserver creates a new floating point ValueObserver with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (BatchObserver) NewInt64SumObserver added in v0.6.0

func (b BatchObserver) NewInt64SumObserver(name string, opts ...InstrumentOption) (Int64SumObserver, error)

NewInt64SumObserver creates a new integer SumObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (BatchObserver) NewInt64UpDownSumObserver added in v0.6.0

func (b BatchObserver) NewInt64UpDownSumObserver(name string, opts ...InstrumentOption) (Int64UpDownSumObserver, error)

NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (BatchObserver) NewInt64ValueObserver added in v0.6.0

func (b BatchObserver) NewInt64ValueObserver(name string, opts ...InstrumentOption) (Int64ValueObserver, error)

NewInt64ValueObserver creates a new integer ValueObserver instrument with the given name, running in a batch callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

type BatchObserverFunc added in v0.11.0

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 added in v0.11.0

func (*BatchObserverFunc) AnyRunner()

AnyRunner implements AsyncRunner.

func (*BatchObserverFunc) Run added in v0.11.0

func (b *BatchObserverFunc) Run(ctx context.Context, function func([]label.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) NewFloat64SumObserver added in v0.6.0

func (bm BatchObserverMust) NewFloat64SumObserver(name string, oos ...InstrumentOption) Float64SumObserver

NewFloat64SumObserver calls `BatchObserver.NewFloat64SumObserver` and returns the instrument, panicking if it encounters an error.

func (BatchObserverMust) NewFloat64UpDownSumObserver added in v0.6.0

func (bm BatchObserverMust) NewFloat64UpDownSumObserver(name string, oos ...InstrumentOption) Float64UpDownSumObserver

NewFloat64UpDownSumObserver calls `BatchObserver.NewFloat64UpDownSumObserver` and returns the instrument, panicking if it encounters an error.

func (BatchObserverMust) NewFloat64ValueObserver added in v0.6.0

func (bm BatchObserverMust) NewFloat64ValueObserver(name string, oos ...InstrumentOption) Float64ValueObserver

NewFloat64ValueObserver calls `BatchObserver.NewFloat64ValueObserver` and returns the instrument, panicking if it encounters an error.

func (BatchObserverMust) NewInt64SumObserver added in v0.6.0

func (bm BatchObserverMust) NewInt64SumObserver(name string, oos ...InstrumentOption) Int64SumObserver

NewInt64SumObserver calls `BatchObserver.NewInt64SumObserver` and returns the instrument, panicking if it encounters an error.

func (BatchObserverMust) NewInt64UpDownSumObserver added in v0.6.0

func (bm BatchObserverMust) NewInt64UpDownSumObserver(name string, oos ...InstrumentOption) Int64UpDownSumObserver

NewInt64UpDownSumObserver calls `BatchObserver.NewInt64UpDownSumObserver` and returns the instrument, panicking if it encounters an error.

func (BatchObserverMust) NewInt64ValueObserver added in v0.6.0

func (bm BatchObserverMust) NewInt64ValueObserver(name string, oos ...InstrumentOption) Int64ValueObserver

NewInt64ValueObserver calls `BatchObserver.NewInt64ValueObserver` 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 []label.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.

func (BoundFloat64Counter) Add added in v0.2.1

func (b BoundFloat64Counter) Add(ctx context.Context, value float64)

Add adds the value to the counter's sum using the labels previously bound to this counter via Bind()

func (BoundFloat64Counter) Unbind added in v0.2.1

func (h BoundFloat64Counter) Unbind()

Unbind calls SyncImpl.Unbind.

type BoundFloat64UpDownCounter added in v0.6.0

type BoundFloat64UpDownCounter struct {
	// contains filtered or unexported fields
}

BoundFloat64UpDownCounter is a bound instrument for Float64UpDownCounter.

It inherits the Unbind function from syncBoundInstrument.

func (BoundFloat64UpDownCounter) Add added in v0.6.0

Add adds the value to the counter's sum using the labels previously bound to this counter via Bind()

func (BoundFloat64UpDownCounter) Unbind added in v0.6.0

func (h BoundFloat64UpDownCounter) Unbind()

Unbind calls SyncImpl.Unbind.

type BoundFloat64ValueRecorder added in v0.6.0

type BoundFloat64ValueRecorder struct {
	// contains filtered or unexported fields
}

BoundFloat64ValueRecorder is a bound instrument for Float64ValueRecorder.

It inherits the Unbind function from syncBoundInstrument.

func (BoundFloat64ValueRecorder) Record added in v0.6.0

func (b BoundFloat64ValueRecorder) Record(ctx context.Context, value float64)

Record adds a new value to the ValueRecorder's distribution using the labels previously bound to the ValueRecorder via Bind().

func (BoundFloat64ValueRecorder) Unbind added in v0.6.0

func (h BoundFloat64ValueRecorder) Unbind()

Unbind calls SyncImpl.Unbind.

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.

func (BoundInt64Counter) Add added in v0.2.1

func (b BoundInt64Counter) Add(ctx context.Context, value int64)

Add adds the value to the counter's sum using the labels previously bound to this counter via Bind()

func (BoundInt64Counter) Unbind added in v0.2.1

func (h BoundInt64Counter) Unbind()

Unbind calls SyncImpl.Unbind.

type BoundInt64UpDownCounter added in v0.6.0

type BoundInt64UpDownCounter struct {
	// contains filtered or unexported fields
}

BoundInt64UpDownCounter is a boundInstrument for Int64UpDownCounter.

It inherits the Unbind function from syncBoundInstrument.

func (BoundInt64UpDownCounter) Add added in v0.6.0

func (b BoundInt64UpDownCounter) Add(ctx context.Context, value int64)

Add adds the value to the counter's sum using the labels previously bound to this counter via Bind()

func (BoundInt64UpDownCounter) Unbind added in v0.6.0

func (h BoundInt64UpDownCounter) Unbind()

Unbind calls SyncImpl.Unbind.

type BoundInt64ValueRecorder added in v0.6.0

type BoundInt64ValueRecorder struct {
	// contains filtered or unexported fields
}

BoundInt64ValueRecorder is a bound instrument for Int64ValueRecorder.

It inherits the Unbind function from syncBoundInstrument.

func (BoundInt64ValueRecorder) Record added in v0.6.0

func (b BoundInt64ValueRecorder) Record(ctx context.Context, value int64)

Record adds a new value to the ValueRecorder's distribution using the labels previously bound to the ValueRecorder via Bind().

func (BoundInt64ValueRecorder) Unbind added in v0.6.0

func (h BoundInt64ValueRecorder) Unbind()

Unbind calls SyncImpl.Unbind.

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 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 ...InstrumentOption) 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) InstrumentationName added in v0.7.0

func (d Descriptor) InstrumentationName() string

InstrumentationName returns the name of the library that provided instrumentation for this instrument.

func (Descriptor) InstrumentationVersion added in v0.7.0

func (d Descriptor) InstrumentationVersion() string

InstrumentationVersion returns the version of the library that provided instrumentation for this instrument.

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

func (c Float64Counter) Add(ctx context.Context, value float64, labels ...label.KeyValue)

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 ...label.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.

func (Float64Counter) SyncImpl added in v0.3.0

func (s Float64Counter) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type Float64ObserverFunc added in v0.11.0

type Float64ObserverFunc func(context.Context, Float64ObserverResult)

Float64ObserverFunc is a type of callback that floating point observers run.

func (*Float64ObserverFunc) AnyRunner added in v0.11.0

func (*Float64ObserverFunc) AnyRunner()

AnyRunner implements AsyncRunner.

func (*Float64ObserverFunc) Run added in v0.11.0

func (f *Float64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]label.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.

func (Float64ObserverResult) Observe added in v0.3.0

func (fr Float64ObserverResult) Observe(value float64, labels ...label.KeyValue)

Observe captures a single floating point value from the associated instrument callback, with the given labels.

type Float64SumObserver added in v0.6.0

type Float64SumObserver struct {
	// contains filtered or unexported fields
}

Float64SumObserver is a metric that captures a precomputed sum of float64 values at a point in time.

func (Float64SumObserver) AsyncImpl added in v0.6.0

func (a Float64SumObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Float64SumObserver) Observation added in v0.6.0

func (f Float64SumObserver) 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 Float64UpDownCounter added in v0.6.0

type Float64UpDownCounter struct {
	// contains filtered or unexported fields
}

Float64UpDownCounter is a metric instrument that sums floating point values.

func (Float64UpDownCounter) Add added in v0.6.0

func (c Float64UpDownCounter) Add(ctx context.Context, value float64, labels ...label.KeyValue)

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 added in v0.6.0

Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.

func (Float64UpDownCounter) Measurement added in v0.6.0

func (c Float64UpDownCounter) Measurement(value float64) Measurement

Measurement creates a Measurement object to use with batch recording.

func (Float64UpDownCounter) SyncImpl added in v0.6.0

func (s Float64UpDownCounter) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type Float64UpDownSumObserver added in v0.6.0

type Float64UpDownSumObserver struct {
	// contains filtered or unexported fields
}

Float64UpDownSumObserver is a metric that captures a precomputed sum of float64 values at a point in time.

func (Float64UpDownSumObserver) AsyncImpl added in v0.6.0

func (a Float64UpDownSumObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Float64UpDownSumObserver) Observation added in v0.6.0

func (f Float64UpDownSumObserver) 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 Float64ValueObserver added in v0.6.0

type Float64ValueObserver struct {
	// contains filtered or unexported fields
}

Float64ValueObserver is a metric that captures a set of float64 values at a point in time.

func (Float64ValueObserver) AsyncImpl added in v0.6.0

func (a Float64ValueObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Float64ValueObserver) Observation added in v0.6.0

func (f Float64ValueObserver) 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 Float64ValueRecorder added in v0.6.0

type Float64ValueRecorder struct {
	// contains filtered or unexported fields
}

Float64ValueRecorder is a metric that records float64 values.

func (Float64ValueRecorder) Bind added in v0.6.0

Bind creates a bound instrument for this ValueRecorder. The labels are associated with values recorded via subsequent calls to Record.

func (Float64ValueRecorder) Measurement added in v0.6.0

func (c Float64ValueRecorder) Measurement(value float64) Measurement

Measurement creates a Measurement object to use with batch recording.

func (Float64ValueRecorder) Record added in v0.6.0

func (c Float64ValueRecorder) Record(ctx context.Context, value float64, labels ...label.KeyValue)

Record adds a new value to the list of ValueRecorder's records. The labels should contain the keys and values to be associated with this value.

func (Float64ValueRecorder) SyncImpl added in v0.6.0

func (s Float64ValueRecorder) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type InstrumentConfig added in v0.7.0

type InstrumentConfig struct {
	// Description describes the instrument in human-readable terms.
	Description string
	// Unit describes the measurement unit for a instrument.
	Unit unit.Unit
	// InstrumentationName is the name of the library providing
	// instrumentation.
	InstrumentationName string
	// InstrumentationVersion is the version of the library providing
	// instrumentation.
	InstrumentationVersion string
}

InstrumentConfig contains options for instrument descriptors.

func NewInstrumentConfig added in v0.12.0

func NewInstrumentConfig(opts ...InstrumentOption) InstrumentConfig

NewInstrumentConfig creates a new InstrumentConfig and applies all the given options.

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 InstrumentOption added in v0.7.0

type InstrumentOption interface {
	// ApplyMeter is used to set a InstrumentOption value of a
	// InstrumentConfig.
	ApplyInstrument(*InstrumentConfig)
}

InstrumentOption is an interface for applying instrument options.

func WithDescription

func WithDescription(desc string) InstrumentOption

WithDescription applies provided description.

func WithInstrumentationName added in v0.7.0

func WithInstrumentationName(name string) InstrumentOption

WithInstrumentationName sets the instrumentation name.

func WithUnit

func WithUnit(unit unit.Unit) InstrumentOption

WithUnit applies provided unit.

type Int64Counter

type Int64Counter struct {
	// contains filtered or unexported fields
}

Int64Counter is a metric that accumulates int64 values.

func (Int64Counter) Add

func (c Int64Counter) Add(ctx context.Context, value int64, labels ...label.KeyValue)

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 ...label.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.

func (Int64Counter) SyncImpl added in v0.3.0

func (s Int64Counter) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type Int64ObserverFunc added in v0.11.0

type Int64ObserverFunc func(context.Context, Int64ObserverResult)

Int64ObserverFunc is a type of callback that integral observers run.

func (*Int64ObserverFunc) AnyRunner added in v0.11.0

func (*Int64ObserverFunc) AnyRunner()

AnyRunner implements AsyncRunner.

func (*Int64ObserverFunc) Run added in v0.11.0

func (i *Int64ObserverFunc) Run(ctx context.Context, impl AsyncImpl, function func([]label.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.

func (Int64ObserverResult) Observe added in v0.3.0

func (ir Int64ObserverResult) Observe(value int64, labels ...label.KeyValue)

Observe captures a single integer value from the associated instrument callback, with the given labels.

type Int64SumObserver added in v0.6.0

type Int64SumObserver struct {
	// contains filtered or unexported fields
}

Int64SumObserver is a metric that captures a precomputed sum of int64 values at a point in time.

func (Int64SumObserver) AsyncImpl added in v0.6.0

func (a Int64SumObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Int64SumObserver) Observation added in v0.6.0

func (i Int64SumObserver) 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 Int64UpDownCounter added in v0.6.0

type Int64UpDownCounter struct {
	// contains filtered or unexported fields
}

Int64UpDownCounter is a metric instrument that sums integer values.

func (Int64UpDownCounter) Add added in v0.6.0

func (c Int64UpDownCounter) Add(ctx context.Context, value int64, labels ...label.KeyValue)

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 added in v0.6.0

Bind creates a bound instrument for this counter. The labels are associated with values recorded via subsequent calls to Record.

func (Int64UpDownCounter) Measurement added in v0.6.0

func (c Int64UpDownCounter) Measurement(value int64) Measurement

Measurement creates a Measurement object to use with batch recording.

func (Int64UpDownCounter) SyncImpl added in v0.6.0

func (s Int64UpDownCounter) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type Int64UpDownSumObserver added in v0.6.0

type Int64UpDownSumObserver struct {
	// contains filtered or unexported fields
}

Int64UpDownSumObserver is a metric that captures a precomputed sum of int64 values at a point in time.

func (Int64UpDownSumObserver) AsyncImpl added in v0.6.0

func (a Int64UpDownSumObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Int64UpDownSumObserver) Observation added in v0.6.0

func (i Int64UpDownSumObserver) 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 Int64ValueObserver added in v0.6.0

type Int64ValueObserver struct {
	// contains filtered or unexported fields
}

Int64ValueObserver is a metric that captures a set of int64 values at a point in time.

func (Int64ValueObserver) AsyncImpl added in v0.6.0

func (a Int64ValueObserver) AsyncImpl() AsyncImpl

AsyncImpl implements AsyncImpl.

func (Int64ValueObserver) Observation added in v0.6.0

func (i Int64ValueObserver) 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 Int64ValueRecorder added in v0.6.0

type Int64ValueRecorder struct {
	// contains filtered or unexported fields
}

Int64ValueRecorder is a metric that records int64 values.

func (Int64ValueRecorder) Bind added in v0.6.0

Bind creates a bound instrument for this ValueRecorder. The labels are associated with values recorded via subsequent calls to Record.

func (Int64ValueRecorder) Measurement added in v0.6.0

func (c Int64ValueRecorder) Measurement(value int64) Measurement

Measurement creates a Measurement object to use with batch recording.

func (Int64ValueRecorder) Record added in v0.6.0

func (c Int64ValueRecorder) Record(ctx context.Context, value int64, labels ...label.KeyValue)

Record adds a new value to the ValueRecorder's distribution. The labels should contain the keys and values to be associated with this value.

func (Int64ValueRecorder) SyncImpl added in v0.6.0

func (s Int64ValueRecorder) SyncImpl() SyncImpl

SyncImpl returns the implementation object for synchronous instruments.

type Kind added in v0.3.0

type Kind int8

Kind describes the kind of instrument.

const (
	// ValueRecorderKind indicates a ValueRecorder instrument.
	ValueRecorderKind Kind = iota
	// ValueObserverKind indicates an ValueObserver instrument.
	ValueObserverKind

	// CounterKind indicates a Counter instrument.
	CounterKind
	// UpDownCounterKind indicates a UpDownCounter instrument.
	UpDownCounterKind

	// SumObserverKind indicates a SumObserver instrument.
	SumObserverKind
	// UpDownSumObserverKind indicates a UpDownSumObserver instrument.
	UpDownSumObserverKind
)

func (Kind) Adding added in v0.7.0

func (k Kind) Adding() bool

Adding returns whether this kind of instrument adds its inputs (as opposed to Grouping).

func (Kind) Asynchronous added in v0.7.0

func (k Kind) Asynchronous() bool

Asynchronous returns whether this is an asynchronous kind of instrument.

func (Kind) Grouping added in v0.7.0

func (k Kind) Grouping() bool

Adding returns whether this kind of instrument groups its inputs (as opposed to Adding).

func (Kind) Monotonic added in v0.7.0

func (k Kind) Monotonic() bool

Monotonic returns whether this kind of instrument exposes a non-decreasing sum.

func (Kind) PrecomputedSum added in v0.7.0

func (k Kind) PrecomputedSum() bool

Cumulative returns whether this kind of instrument receives precomputed sums.

func (Kind) String added in v0.3.0

func (i Kind) String() string

func (Kind) Synchronous added in v0.7.0

func (k Kind) Synchronous() bool

Synchronous returns whether this is a synchronous kind of instrument.

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 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

func WrapMeterImpl(impl MeterImpl, instrumentationName string, opts ...MeterOption) Meter

WrapMeterImpl constructs a `Meter` implementation from a `MeterImpl` implementation.

func (Meter) MeterImpl added in v0.5.0

func (m Meter) MeterImpl() MeterImpl

MeterImpl returns the underlying MeterImpl of this Meter.

func (Meter) NewBatchObserver added in v0.5.0

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) NewFloat64SumObserver added in v0.6.0

func (m Meter) NewFloat64SumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64SumObserver, error)

NewFloat64SumObserver creates a new floating point SumObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewFloat64UpDownCounter added in v0.6.0

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) NewFloat64UpDownSumObserver added in v0.6.0

func (m Meter) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64UpDownSumObserver, error)

NewFloat64UpDownSumObserver creates a new floating point UpDownSumObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewFloat64ValueObserver added in v0.6.0

func (m Meter) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, opts ...InstrumentOption) (Float64ValueObserver, error)

NewFloat64ValueObserver creates a new floating point ValueObserver with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewFloat64ValueRecorder added in v0.6.0

func (m Meter) NewFloat64ValueRecorder(name string, opts ...InstrumentOption) (Float64ValueRecorder, error)

NewFloat64ValueRecorder creates a new floating point ValueRecorder with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (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) NewInt64SumObserver added in v0.6.0

func (m Meter) NewInt64SumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64SumObserver, error)

NewInt64SumObserver creates a new integer SumObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewInt64UpDownCounter added in v0.6.0

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) NewInt64UpDownSumObserver added in v0.6.0

func (m Meter) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64UpDownSumObserver, error)

NewInt64UpDownSumObserver creates a new integer UpDownSumObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewInt64ValueObserver added in v0.6.0

func (m Meter) NewInt64ValueObserver(name string, callback Int64ObserverFunc, opts ...InstrumentOption) (Int64ValueObserver, error)

NewInt64ValueObserver creates a new integer ValueObserver instrument with the given name, running a given callback, and customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) NewInt64ValueRecorder added in v0.6.0

func (m Meter) NewInt64ValueRecorder(name string, opts ...InstrumentOption) (Int64ValueRecorder, error)

NewInt64ValueRecorder creates a new integer ValueRecorder instrument with the given name, customized with options. May return an error if the name is invalid (e.g., empty) or improperly registered (e.g., duplicate registration).

func (Meter) RecordBatch

func (m Meter) RecordBatch(ctx context.Context, ls []label.KeyValue, ms ...Measurement)

RecordBatch atomically records a batch of measurements.

type MeterConfig added in v0.7.0

type MeterConfig struct {
	// InstrumentationVersion is the version of the library providing
	// instrumentation.
	InstrumentationVersion string
}

MeterConfig contains options for Meters.

func NewMeterConfig added in v0.12.0

func NewMeterConfig(opts ...MeterOption) MeterConfig

NewMeterConfig creates a new MeterConfig and applies all the given options.

type MeterImpl added in v0.3.0

type MeterImpl interface {
	// RecordBatch atomically records a batch of measurements.
	RecordBatch(ctx context.Context, labels []label.KeyValue, measurement ...Measurement)

	// NewSyncInstrument returns a newly constructed
	// synchronous instrument implementation or an error, should
	// one occur.
	NewSyncInstrument(descriptor Descriptor) (SyncImpl, error)

	// NewAsyncInstrument returns a newly constructed
	// asynchronous instrument implementation or an error, should
	// one occur.
	NewAsyncInstrument(
		descriptor Descriptor,
		runner AsyncRunner,
	) (AsyncImpl, error)
}

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

func Must(meter Meter) MeterMust

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 BatchObserverFunc) 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 ...InstrumentOption) Float64Counter

NewFloat64Counter calls `Meter.NewFloat64Counter` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewFloat64SumObserver added in v0.6.0

func (mm MeterMust) NewFloat64SumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64SumObserver

NewFloat64SumObserver calls `Meter.NewFloat64SumObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewFloat64UpDownCounter added in v0.6.0

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) NewFloat64UpDownSumObserver added in v0.6.0

func (mm MeterMust) NewFloat64UpDownSumObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64UpDownSumObserver

NewFloat64UpDownSumObserver calls `Meter.NewFloat64UpDownSumObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewFloat64ValueObserver added in v0.6.0

func (mm MeterMust) NewFloat64ValueObserver(name string, callback Float64ObserverFunc, oos ...InstrumentOption) Float64ValueObserver

NewFloat64ValueObserver calls `Meter.NewFloat64ValueObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewFloat64ValueRecorder added in v0.6.0

func (mm MeterMust) NewFloat64ValueRecorder(name string, mos ...InstrumentOption) Float64ValueRecorder

NewFloat64ValueRecorder calls `Meter.NewFloat64ValueRecorder` 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 ...InstrumentOption) Int64Counter

NewInt64Counter calls `Meter.NewInt64Counter` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewInt64SumObserver added in v0.6.0

func (mm MeterMust) NewInt64SumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64SumObserver

NewInt64SumObserver calls `Meter.NewInt64SumObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewInt64UpDownCounter added in v0.6.0

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) NewInt64UpDownSumObserver added in v0.6.0

func (mm MeterMust) NewInt64UpDownSumObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64UpDownSumObserver

NewInt64UpDownSumObserver calls `Meter.NewInt64UpDownSumObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewInt64ValueObserver added in v0.6.0

func (mm MeterMust) NewInt64ValueObserver(name string, callback Int64ObserverFunc, oos ...InstrumentOption) Int64ValueObserver

NewInt64ValueObserver calls `Meter.NewInt64ValueObserver` and returns the instrument, panicking if it encounters an error.

func (MeterMust) NewInt64ValueRecorder added in v0.6.0

func (mm MeterMust) NewInt64ValueRecorder(name string, mos ...InstrumentOption) Int64ValueRecorder

NewInt64ValueRecorder calls `Meter.NewInt64ValueRecorder` and returns the instrument, panicking if it encounters an error.

type MeterOption added in v0.7.0

type MeterOption interface {
	// ApplyMeter is used to set a MeterOption value of a MeterConfig.
	ApplyMeter(*MeterConfig)
}

MeterOption is an interface for applying Meter options.

type MeterProvider added in v0.12.0

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 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 NoopMeterProvider added in v0.12.0

type NoopMeterProvider struct{}

func (NoopMeterProvider) Meter added in v0.12.0

func (NoopMeterProvider) Meter(_ string, _ ...MeterOption) Meter

type NoopSync added in v0.3.0

type NoopSync struct {
	// contains filtered or unexported fields
}

func (NoopSync) Bind added in v0.3.0

func (NoopSync) Descriptor added in v0.3.0

func (NoopSync) Descriptor() Descriptor

func (NoopSync) Implementation added in v0.3.0

func (NoopSync) Implementation() interface{}

func (NoopSync) RecordOne added in v0.3.0

func (NoopSync) RecordOne(context.Context, Number, []label.KeyValue)

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

func NewFloat64Number(f float64) Number

NewFloat64Number creates a floating point Number.

func NewInt64Number added in v0.5.0

func NewInt64Number(i int64) Number

NewInt64Number creates an integral Number.

func NewNumberFromRaw added in v0.5.0

func NewNumberFromRaw(r uint64) Number

NewNumberFromRaw creates a new Number from a raw value.

func NewNumberSignChange added in v0.7.0

func NewNumberSignChange(kind NumberKind, nn Number) Number

NewNumberSignChange returns a number with the same magnitude and the opposite sign. `kind` must describe the kind of number in `nn`.

Does not change Uint64NumberKind values.

func (*Number) AddFloat64 added in v0.5.0

func (n *Number) AddFloat64(f float64)

AddFloat64 assumes that the number contains a float64 and adds the passed float64 to it.

func (*Number) AddFloat64Atomic added in v0.5.0

func (n *Number) AddFloat64Atomic(f float64)

AddFloat64Atomic assumes that the number contains a float64 and adds the passed float64 to it atomically.

func (*Number) AddInt64 added in v0.5.0

func (n *Number) AddInt64(i int64)

AddInt64 assumes that the number contains an int64 and adds the passed int64 to it.

func (*Number) AddInt64Atomic added in v0.5.0

func (n *Number) AddInt64Atomic(i int64)

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) AsFloat64 added in v0.5.0

func (n *Number) AsFloat64() float64

AsFloat64 assumes that the measurement value contains a float64 and returns it as such.

func (*Number) AsFloat64Atomic added in v0.5.0

func (n *Number) AsFloat64Atomic() float64

AsFloat64Atomic assumes that the measurement value contains a float64 and returns it as such atomically.

func (*Number) AsFloat64Ptr added in v0.5.0

func (n *Number) AsFloat64Ptr() *float64

AsFloat64Ptr assumes that the number contains a float64 and returns a pointer to it.

func (*Number) AsInt64 added in v0.5.0

func (n *Number) AsInt64() int64

AsInt64 assumes that the value contains an int64 and returns it as such.

func (*Number) AsInt64Atomic added in v0.5.0

func (n *Number) AsInt64Atomic() int64

AsInt64Atomic assumes that the number contains an int64 and returns it as such atomically.

func (*Number) AsInt64Ptr added in v0.5.0

func (n *Number) AsInt64Ptr() *int64

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) AsNumber added in v0.5.0

func (n *Number) AsNumber() Number

AsNumber gets the Number.

func (*Number) AsNumberAtomic added in v0.5.0

func (n *Number) AsNumberAtomic() Number

AsNumberAtomic gets the Number atomically.

func (*Number) AsRaw added in v0.5.0

func (n *Number) AsRaw() uint64

AsRaw gets the uninterpreted raw value. Might be useful for some atomic operations.

func (*Number) AsRawAtomic added in v0.5.0

func (n *Number) AsRawAtomic() uint64

AsRawAtomic gets the uninterpreted raw value atomically. Might be useful for some atomic operations.

func (*Number) AsRawPtr added in v0.5.0

func (n *Number) AsRawPtr() *uint64

AsRawPtr gets the pointer to the raw, uninterpreted raw value. Might be useful for some atomic operations.

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) CompareAndSwapFloat64 added in v0.5.0

func (n *Number) CompareAndSwapFloat64(of, nf float64) bool

CompareAndSwapFloat64 assumes that this number contains a float64 and does the atomic CAS operation on it.

func (*Number) CompareAndSwapInt64 added in v0.5.0

func (n *Number) CompareAndSwapInt64(oi, ni int64) bool

CompareAndSwapInt64 assumes that this number contains an int64 and does the atomic CAS operation on it.

func (*Number) CompareAndSwapNumber added in v0.5.0

func (n *Number) CompareAndSwapNumber(on, nn Number) bool

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

func (n *Number) CompareAndSwapRaw(or, nr uint64) bool

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) CompareFloat64 added in v0.5.0

func (n *Number) CompareFloat64(f float64) int

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

func (n *Number) CompareInt64(i int64) int

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) 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

func (n *Number) SetFloat64(f float64)

SetFloat64 assumes that the number contains a float64 and sets it to the passed value.

func (*Number) SetFloat64Atomic added in v0.5.0

func (n *Number) SetFloat64Atomic(f float64)

SetFloat64Atomic assumes that the number contains a float64 and sets it to the passed value atomically.

func (*Number) SetInt64 added in v0.5.0

func (n *Number) SetInt64(i int64)

SetInt64 assumes that the number contains an int64 and sets it to the passed value.

func (*Number) SetInt64Atomic added in v0.5.0

func (n *Number) SetInt64Atomic(i int64)

SetInt64Atomic assumes that the number contains an int64 and sets it to the passed value atomically.

func (*Number) SetNumber added in v0.5.0

func (n *Number) SetNumber(nn Number)

SetNumber sets the number to the passed number. Both should be of the same kind.

func (*Number) SetNumberAtomic added in v0.5.0

func (n *Number) SetNumberAtomic(nn Number)

SetNumberAtomic sets the number to the passed number atomically. Both should be of the same kind.

func (*Number) SetRaw added in v0.5.0

func (n *Number) SetRaw(r uint64)

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

func (n *Number) SetRawAtomic(r uint64)

SetRawAtomic sets the number to the passed raw value atomically. Both number and the raw number should represent the same kind.

func (*Number) SwapFloat64 added in v0.5.0

func (n *Number) SwapFloat64(f float64) float64

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

func (n *Number) SwapFloat64Atomic(f float64) float64

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

func (n *Number) SwapInt64(i int64) int64

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

func (n *Number) SwapInt64Atomic(i int64) int64

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

func (n *Number) SwapNumber(nn Number) Number

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

func (n *Number) SwapNumberAtomic(nn Number) Number

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

func (n *Number) SwapRaw(r uint64) uint64

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

func (n *Number) SwapRawAtomic(r uint64) uint64

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.

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
)

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 an asynchronous batch of metric values. Instances of this type should be created by asynchronous instruments (e.g., Int64ValueObserver.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 {
	InstrumentOption
	MeterOption
}

Option is an interface for applying Instrument or Meter options.

func WithInstrumentationVersion added in v0.7.0

func WithInstrumentationVersion(version string) Option

WithInstrumentationVersion sets the instrumentation version.

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 []label.KeyValue) BoundSyncImpl

	// RecordOne captures a single synchronous metric event.
	RecordOne(ctx context.Context, number Number, labels []label.KeyValue)
}

SyncImpl is the implementation-level interface to a generic synchronous instrument (e.g., ValueRecorder and Counter instruments).

Directories

Path Synopsis
Package metrictest contains utilities for testing metrics.
Package metrictest contains utilities for testing metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL