Histogram constructor

Histogram({
  1. required String name,
  2. required String help,
  3. List<String> labelNames = const [],
  4. List<double> buckets = defaultBuckets,
  5. Collect<Histogram>? collectCallback,
})

Construct a new Histogram with a name, help text, optional labelNames and optional upper bounds for the buckets. If labelNames are provided, use labels(...) to assign label values. buckets have to be sorted in ascending order. If no buckets are provided the defaultBuckets are used instead. The optional collectCallback is called at the beginning of collect and allows to update the value of the histogram before collecting it.

Implementation

Histogram({
  required String name,
  required String help,
  List<String> labelNames = const [],
  List<double> buckets = defaultBuckets,
  this.collectCallback,
})  : buckets = List.unmodifiable(_sanitizeBuckets(buckets)),
      super(name: name, help: help, labelNames: labelNames) {
  if (labelNames.contains(leLabel)) {
    throw ArgumentError.value(labelNames, 'labelNames',
        '"le" is a reserved label name for a histogram.');
  }
}