HistogramMetric class

A histogram metric for use with TelemetryService.

A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.

A histogram with a base metric name of <basename> exposes multiple time series during a scrape:

  • cumulative counters for the observation buckets, exposed as <basename>_bucket{le="<upper inclusive bound>"}
  • the total sum of all observed values, exposed as <basename>_sum
  • the count of events that have been observed, exposed as <basename>_count (identical to <basename>_bucket{le="+Inf"} above)

Best practice for creating metric instances is by using the metric definition methods on TelemetryService:

  • counter
  • gauge
  • linearHistogram
  • exponentialHistogram

This way, the same metric can be injected from different places inside the application. Metrics can be instantiated anywhere and registered at the TelemetryService either through the ServiceResolver by invoking the register method.

Inheritance

Constructors

HistogramMetric.exponential(String name, {required num start, required num factor, required int count, String? help})
HistogramMetric.linear(String name, {required num start, required num width, required int count, String? help})

Properties

hashCode int
The hash code for this object.
no setterinherited
help String?
finalinherited
name String
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type MetricType
finalinherited

Methods

collect() SampleGroup
override
measureDuration<T>(FutureOr<T> delegate()) FutureOr<T>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observe(num value) → void
observeDuration(Duration duration) → void
register() → void
inherited
toString() String
A string representation of this object.
inherited

Operators

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