ObservableCounter<T extends num> class

ObservableCounter is an asynchronous instrument that reports monotonically increasing values when observed.

An ObservableCounter is used to measure monotonically increasing values where measurements are made by a callback function. For example, CPU time, bytes received, or number of operations.

Implemented types

Constructors

ObservableCounter({required APIObservableCounter<T> apiCounter, required Meter meter})
Creates a new ObservableCounter instance.

Properties

advisory → InstrumentAdvisory?
Returns the advisory parameters of this observable counter.
no setteroverride
callbacks → List<ObservableCallback<T>>
Returns the current list of callbacks registered to this instrument.
no setteroverride
description → String?
Returns the description of this observable counter.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
meter → APIMeter
Returns the meter that created this observable counter.
no setteroverride
name → String
Returns the name of this observable counter.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
unit → String?
Returns the unit of this observable counter.
no setteroverride

Methods

addCallback(ObservableCallback<T> callback) → APICallbackRegistration<T>
Registers a callback function that will be invoked when the instrument is observed. Returns a registration handle that can be used to unregister the callback.
override
collect() → List<Measurement<T>>
Collects measurements from all registered callbacks and from any batch callbacks that observed this instrument since the last collection.
override
collectMetrics() → List<Metric>
Collects metrics for the SDK metric export.
override
collectPoints() → List<MetricPoint<T>>
Gets the current points for this counter. This is used by the SDK to collect metrics.
getValue([Attributes? attributes]) → T
Gets the current value of the counter for a specific set of attributes. If no attributes are provided, returns the sum of all recorded values.
isEnabled() → bool
Returns whether the instrument is enabled and will record measurements.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observeFromBatch(num value, Attributes? attributes) → void
Queues a measurement observed by a batch callback for the next collection. The value is converted to the instrument's numeric type.
override
removeCallback(ObservableCallback<T> callback) → void
Removes a callback from this instrument by direct reference.
override
reset() → void
Resets the counter. This is only used for testing.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited