createObservableCounter<T extends num> method

APIObservableCounter<T> createObservableCounter<T extends num>({
  1. required String name,
  2. String? unit,
  3. String? description,
  4. ObservableCallback<T>? callback,
})

Creates an ObservableCounter with the given name.

An ObservableCounter is an asynchronous Instrument which reports monotonically increasing value(s) when the instrument is being observed.

name The name of the instrument unit Optional unit of the instrument (e.g., "ms" for milliseconds) description Optional description of the instrument callback Optional callback to provide measurements when the instrument is observed

Implementation

APIObservableCounter<T> createObservableCounter<T extends num>({
  required String name,
  String? unit,
  String? description,
  ObservableCallback<T>? callback,
}) {
  if (name.isEmpty) {
    throw ArgumentError('ObservableCounter name must not be empty');
  }

  return ObservableCounterCreate.create<T>(
    name: name,
    unit: unit,
    description: description,
    meter: this,
    callback: callback,
  );
}