observeDurationSync<T> method

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

Observe the duration of callback and store it in the summary with labels.

Implementation

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