observeDurationSync<T> method Null safety

T observeDurationSync<T>(
  1. T callback(
      )
    )

    Observe the duration of callback and store it in the corresponding buckets of a histogram with labels.

    Implementation

    T observeDurationSync<T>(T Function() callback) {
      final stopwatch = Stopwatch()..start();
      try {
        return callback();
      } finally {
        observe(stopwatch.elapsedMicroseconds / Duration.microsecondsPerSecond);
      }
    }