Involved Source Filesasync.goconfig.gocounter.godescriptor.go
metric package provides an API for reporting diagnostic
measurements using instruments categorized as follows:
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 Provider.
The Provider interface supports obtaining a named Meter interface.
To obtain a Provider implementation, initialize and configure any
compatible SDK.
kind.gokind_string.gometer.gomust.gonoop.gonumber.gonumberkind_string.goobserver.gosdkapi.gosync.goupdowncounter.govaluerecorder.go
Package-Level Type Names (total 60, in which 51 are exported)
/* sort exporteds by: | */
AsyncBatchRunner is an interface implemented by batch-observer
callbacks.
AnyRunner() is a non-exported method with no functional use
other than to make this a non-empty interface.
Run accepts a function for capturing observations of
multiple instruments.
*BatchObserverFunc
T : AsyncRunner
func newBatchAsyncRunner(c BatchObserverFunc) AsyncBatchRunner
AsyncSingleRunner is an interface implemented by single-observer
callbacks.
AnyRunner() is a non-exported method with no functional use
other than to make this a non-empty 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.)
*Float64ObserverFunc
*Int64ObserverFunc
T : AsyncRunner
func newFloat64AsyncRunner(c Float64ObserverFunc) AsyncSingleRunner
func newInt64AsyncRunner(c Int64ObserverFunc) AsyncSingleRunner
BatchObserver represents an Observer callback that can report
observations for multiple instruments.
meterMeterrunnerAsyncBatchRunner
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).
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).
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).
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).
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).
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).
func Meter.NewBatchObserver(callback BatchObserverFunc) BatchObserver
BatchObserverMust is a wrapper for BatchObserver that panics when
any instrument constructor encounters an error.
batchBatchObserver
NewFloat64SumObserver calls `BatchObserver.NewFloat64SumObserver` and
returns the instrument, panicking if it encounters an error.
NewFloat64UpDownSumObserver calls `BatchObserver.NewFloat64UpDownSumObserver` and
returns the instrument, panicking if it encounters an error.
NewFloat64ValueObserver calls `BatchObserver.NewFloat64ValueObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64SumObserver calls `BatchObserver.NewInt64SumObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64UpDownSumObserver calls `BatchObserver.NewInt64UpDownSumObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64ValueObserver calls `BatchObserver.NewInt64ValueObserver` and
returns the instrument, panicking if it encounters an error.
func MeterMust.NewBatchObserver(callback BatchObserverFunc) BatchObserverMust
BatchObserverResult is passed to a batch observer callback to
capture observations for multiple asynchronous instruments.
functionfunc([]label.KeyValue, ...Observation)
Observe captures a multiple observations from the associated batch
instrument callback, with the given labels.
BoundSyncImpl is the implementation-level interface to a
generic bound synchronous instrument
RecordOne captures a single synchronous metric event.
Unbind frees the resources associated with this bound instrument. It
does not affect the metric this bound instrument was created through.
noopBoundInstrument
*go.opentelemetry.io/otel/api/global/internal.syncHandle
func NoopSync.Bind([]label.KeyValue) BoundSyncImpl
func SyncImpl.Bind(labels []label.KeyValue) BoundSyncImpl
func newSyncBoundInstrument(boundInstrument BoundSyncImpl) syncBoundInstrument
Descriptor contains all the settings that describe an instrument,
including its name, metric kind, number kind, and the configurable
options.
configInstrumentConfigkindKindnamestringnumberKindNumberKind
Description provides a human-readable description of the metric
instrument.
InstrumentationName returns the name of the library that provided
instrumentation for this instrument.
InstrumentationVersion returns the version of the library that provided
instrumentation for this instrument.
MetricKind returns the specific kind of instrument.
Name returns the metric instrument's name.
NumberKind returns whether this instrument is declared over int64,
float64, or uint64 values.
Unit describes the units of the metric instrument. Unitless
metrics return the empty string.
func NewDescriptor(name string, mkind Kind, nkind NumberKind, opts ...InstrumentOption) Descriptor
func AsyncImpl.Descriptor() Descriptor
func InstrumentImpl.Descriptor() Descriptor
func SyncImpl.Descriptor() Descriptor
func MeterImpl.NewAsyncInstrument(descriptor Descriptor, runner AsyncRunner) (AsyncImpl, error)
func MeterImpl.NewSyncInstrument(descriptor Descriptor) (SyncImpl, error)
func go.opentelemetry.io/otel/api/metric/registry.Compatible(candidate, existing Descriptor) bool
func go.opentelemetry.io/otel/api/metric/registry.NewMetricKindMismatchError(desc Descriptor) error
func go.opentelemetry.io/otel/api/metric/registry.keyOf(descriptor Descriptor) registry.key
Float64ObserverResult is passed to an observer callback to capture
observations for one asynchronous floating point metric instrument.
functionfunc([]label.KeyValue, ...Observation)instrumentAsyncImpl
Observe captures a single floating point value from the associated
instrument callback, with the given labels.
InstrumentConfig contains options for instrument descriptors.
Description describes the instrument in human-readable terms.
InstrumentationName is the name of the library providing
instrumentation.
InstrumentationVersion is the version of the library providing
instrumentation.
Unit describes the measurement unit for a instrument.
func ConfigureInstrument(opts []InstrumentOption) InstrumentConfig
func InstrumentOption.ApplyInstrument(*InstrumentConfig)
func Option.ApplyInstrument(*InstrumentConfig)
InstrumentImpl is a common interface for synchronous and
asynchronous instruments.
Descriptor returns a copy of the instrument's Descriptor.
Implementation returns the underlying implementation of the
instrument, which allows the implementation to gain access
to its own representation especially from a `Measurement`.
AsyncImpl(interface)NoopAsyncNoopSyncSyncImpl(interface)noopInstrument
*go.opentelemetry.io/otel/api/global/internal.asyncImpl
*go.opentelemetry.io/otel/api/global/internal.syncImpl
T : AsyncImpl
Int64ObserverResult is passed to an observer callback to capture
observations for one asynchronous integer metric instrument.
functionfunc([]label.KeyValue, ...Observation)instrumentAsyncImpl
Observe captures a single integer value from the associated
instrument callback, with the given labels.
Meter is the OpenTelemetry metric API, based on a `MeterImpl`
implementation and the `Meter` library name.
An uninitialized Meter is a no-op implementation.
implMeterImplnamestringversionstring
MeterImpl returns the underlying MeterImpl of this Meter.
NewBatchObserver creates a new BatchObserver that supports
making batches of observations for multiple instruments.
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).
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).
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).
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).
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).
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).
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).
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).
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).
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).
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).
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).
RecordBatch atomically records a batch of measurements.
newAsync constructs one new asynchronous instrument.
newSync constructs one new synchronous instrument.
func WrapMeterImpl(impl MeterImpl, instrumentatioName string, opts ...MeterOption) Meter
func NoopProvider.Meter(_ string, _ ...MeterOption) Meter
func Provider.Meter(instrumentationName string, opts ...MeterOption) Meter
func go.opentelemetry.io/otel/api/metric/registry.(*Provider).Meter(instrumentationName string, opts ...MeterOption) Meter
func go.opentelemetry.io/otel/api/global.Meter(instrumentationName string, opts ...MeterOption) Meter
func Must(meter Meter) MeterMust
MeterConfig contains options for Meters.
InstrumentationVersion is the version of the library providing
instrumentation.
func ConfigureMeter(opts []MeterOption) MeterConfig
func MeterOption.ApplyMeter(*MeterConfig)
func Option.ApplyMeter(*MeterConfig)
MeterImpl is the interface an SDK must implement to supply a Meter
implementation.
NewAsyncInstrument returns a newly constructed
asynchronous instrument implementation or an error, should
one occur.
NewSyncInstrument returns a newly constructed
synchronous instrument implementation or an error, should
one occur.
RecordBatch atomically records a batch of measurements.
*go.opentelemetry.io/otel/api/metric/registry.uniqueInstrumentMeterImpl
*go.opentelemetry.io/otel/api/global/internal.meterImpl
func Meter.MeterImpl() MeterImpl
func go.opentelemetry.io/otel/api/metric/registry.NewUniqueInstrumentMeterImpl(impl MeterImpl) MeterImpl
func WrapMeterImpl(impl MeterImpl, instrumentatioName string, opts ...MeterOption) Meter
func go.opentelemetry.io/otel/api/metric/registry.NewProvider(impl MeterImpl) *registry.Provider
func go.opentelemetry.io/otel/api/metric/registry.NewUniqueInstrumentMeterImpl(impl MeterImpl) MeterImpl
MeterMust is a wrapper for Meter interfaces that panics when any
instrument constructor encounters an error.
meterMeter
NewBatchObserver returns a wrapper around BatchObserver that panics
when any instrument constructor returns an error.
NewFloat64Counter calls `Meter.NewFloat64Counter` and returns the
instrument, panicking if it encounters an error.
NewFloat64SumObserver calls `Meter.NewFloat64SumObserver` and
returns the instrument, panicking if it encounters an error.
NewFloat64UpDownCounter calls `Meter.NewFloat64UpDownCounter` and returns the
instrument, panicking if it encounters an error.
NewFloat64UpDownSumObserver calls `Meter.NewFloat64UpDownSumObserver` and
returns the instrument, panicking if it encounters an error.
NewFloat64ValueObserver calls `Meter.NewFloat64ValueObserver` and
returns the instrument, panicking if it encounters an error.
NewFloat64ValueRecorder calls `Meter.NewFloat64ValueRecorder` and returns the
instrument, panicking if it encounters an error.
NewInt64Counter calls `Meter.NewInt64Counter` and returns the
instrument, panicking if it encounters an error.
NewInt64SumObserver calls `Meter.NewInt64SumObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64UpDownCounter calls `Meter.NewInt64UpDownCounter` and returns the
instrument, panicking if it encounters an error.
NewInt64UpDownSumObserver calls `Meter.NewInt64UpDownSumObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64ValueObserver calls `Meter.NewInt64ValueObserver` and
returns the instrument, panicking if it encounters an error.
NewInt64ValueRecorder calls `Meter.NewInt64ValueRecorder` and returns the
instrument, panicking if it encounters an error.
func Must(meter Meter) MeterMust
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.
AddFloat64 assumes that the number contains a float64 and adds the
passed float64 to it.
AddFloat64Atomic assumes that the number contains a float64 and
adds the passed float64 to it atomically.
AddInt64 assumes that the number contains an int64 and adds the
passed int64 to it.
AddInt64Atomic assumes that the number contains an int64 and adds
the passed int64 to it atomically.
AddNumber assumes that this and the passed number are of the passed
kind and adds the passed number to this number.
AddNumberAtomic assumes that this and the passed number are of the
passed kind and adds the passed number to this number atomically.
AddRaw assumes that this number and the passed raw value are of the
passed kind and adds the passed raw value to this number.
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.
AsFloat64 assumes that the measurement value contains a float64 and
returns it as such.
AsFloat64Atomic assumes that the measurement value contains a
float64 and returns it as such atomically.
AsFloat64Ptr assumes that the number contains a float64 and returns a
pointer to it.
AsInt64 assumes that the value contains an int64 and returns it as
such.
AsInt64Atomic assumes that the number contains an int64 and returns
it as such atomically.
AsInt64Ptr assumes that the number contains an int64 and returns a
pointer to it.
AsInterface returns the number as an interface{}, typically used
for NumberKind-correct JSON conversion.
AsNumber gets the Number.
AsNumberAtomic gets the Number atomically.
AsRaw gets the uninterpreted raw value. Might be useful for some
atomic operations.
AsRawAtomic gets the uninterpreted raw value atomically. Might be
useful for some atomic operations.
AsRawPtr gets the pointer to the raw, uninterpreted raw
value. Might be useful for some atomic operations.
CoerceToFloat64 casts the number to float64. May result in
data/precision loss.
CoerceToInt64 casts the number to int64. May result in
data/precision loss.
CompareAndSwapFloat64 assumes that this number contains a float64 and
does the atomic CAS operation on it.
CompareAndSwapInt64 assumes that this number contains an int64 and
does the atomic CAS operation on it.
CompareAndSwapNumber does the atomic CAS operation on this
number. This number and passed old and new numbers should be of the
same kind.
CompareAndSwapRaw does the atomic CAS operation on this
number. This number and passed old and new raw values should be of
the same kind.
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.
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.
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`
CompareRaw compares two numbers, where one is input as a raw
uint64, interpreting both values as a `kind` of number.
Emit returns a string representation of the raw value of the
Number. A %d is used for integral values, %f for floating point
values.
IsNegative returns true if the actual value is less than zero.
IsPositive returns true if the actual value is greater than zero.
IsZero returns true if the actual value is equal to zero.
SetFloat64 assumes that the number contains a float64 and sets it
to the passed value.
SetFloat64Atomic assumes that the number contains a float64 and
sets it to the passed value atomically.
SetInt64 assumes that the number contains an int64 and sets it to
the passed value.
SetInt64Atomic assumes that the number contains an int64 and sets
it to the passed value atomically.
SetNumber sets the number to the passed number. Both should be of
the same kind.
SetNumberAtomic sets the number to the passed number
atomically. Both should be of the same kind.
SetRaw sets the number to the passed raw value. Both number and the
raw number should represent the same kind.
SetRawAtomic sets the number to the passed raw value
atomically. Both number and the raw number should represent the
same kind.
SwapFloat64 assumes that the number contains an float64, sets it to
the passed value and returns the old float64 value.
SwapFloat64Atomic assumes that the number contains an float64, sets
it to the passed value and returns the old float64 value
atomically.
SwapInt64 assumes that the number contains an int64, sets it to the
passed value and returns the old int64 value.
SwapInt64Atomic assumes that the number contains an int64, sets it
to the passed value and returns the old int64 value atomically.
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.
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.
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.
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.
(*T) compareWithZero(kind NumberKind) int
func NewFloat64Number(f float64) Number
func NewInt64Number(i int64) Number
func NewNumberFromRaw(r uint64) Number
func NewNumberSignChange(kind NumberKind, nn Number) Number
func Measurement.Number() Number
func (*Number).AsNumber() Number
func (*Number).AsNumberAtomic() Number
func (*Number).SwapNumber(nn Number) Number
func (*Number).SwapNumberAtomic(nn Number) Number
func NumberKind.Maximum() Number
func NumberKind.Minimum() Number
func NumberKind.Zero() Number
func Observation.Number() Number
func NewNumberSignChange(kind NumberKind, nn Number) Number
func BoundSyncImpl.RecordOne(ctx context.Context, number Number)
func NoopSync.RecordOne(context.Context, Number, []label.KeyValue)
func (*Number).AddNumber(kind NumberKind, nn Number)
func (*Number).AddNumberAtomic(kind NumberKind, nn Number)
func (*Number).CompareAndSwapNumber(on, nn Number) bool
func (*Number).CompareNumber(kind NumberKind, nn Number) int
func (*Number).SetNumber(nn Number)
func (*Number).SetNumberAtomic(nn Number)
func (*Number).SwapNumber(nn Number) Number
func (*Number).SwapNumberAtomic(nn Number) Number
func SyncImpl.RecordOne(ctx context.Context, number Number, labels []label.KeyValue)
func newMeasurement(instrument SyncImpl, number Number) Measurement
Provider supports named Meter instances.
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.
NoopProvider
*go.opentelemetry.io/otel/api/metric/registry.Provider
*go.opentelemetry.io/otel/api/global/internal.meterProvider
func go.opentelemetry.io/otel/api/global.MeterProvider() Provider
func go.opentelemetry.io/otel/api/global/internal.MeterProvider() Provider
func go.opentelemetry.io/otel/api/global.SetMeterProvider(mp Provider)
func go.opentelemetry.io/otel/api/global/internal.SetMeterProvider(mp Provider)
Package-Level Functions (total 32, in which 13 are exported)
ConfigureInstrument is a helper that applies all the InstrumentOptions
to an InstrumentConfig.
ConfigureMeter is a helper that applies all the MeterOptions to a
MeterConfig.
Must constructs a MeterMust implementation from a Meter, allowing
the application to panic when any instrument constructor yields an
error.
NewDescriptor returns a Descriptor with the given contents.
NewFloat64Number creates a floating point Number.
NewInt64Number creates an integral Number.
NewNumberFromRaw creates a new Number from a raw value.
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.
WithDescription applies provided description.
WithInstrumentationName sets the instrumentation name.
WithInstrumentationVersion sets the instrumentation version.
WithUnit applies provided unit.
WrapMeterImpl constructs a `Meter` implementation from a
`MeterImpl` implementation.
checkNewAsync receives an AsyncImpl and potential
error, and returns the same types, checking for and ensuring that
the returned interface is not nil.
checkNewSync receives an SyncImpl and potential
error, and returns the same types, checking for and ensuring that
the returned interface is not nil.
newBatchAsyncRunner returns a batch-observer callback use with multiple Observer instruments.
newFloat64AsyncRunner returns a single-observer callback for floating point Observer instruments.
newInt64AsyncRunner returns a single-observer callback for integer Observer instruments.
The pages are generated with Goldsv0.3.2-preview. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.