incrementCounter static method

void incrementCounter(
  1. String name, {
  2. Map<String, String>? tags,
})

Increments a counter metric.

Implementation

static void incrementCounter(String name, {Map<String, String>? tags}) {
  if (!_enabled) return;

  final key = _keyWithTags(name, tags);
  _counters[key] = (_counters[key] ?? 0) + 1;

  record(
    Metric(
      name: name,
      type: MetricType.counter,
      value: _counters[key]!,
      tags: tags,
    ),
  );
}