time method
Log the time delta for a metric
Implementation
Metric time(
String name,
Stopwatch stopwatch, {
int? interval,
List<String> tags = const <String>[],
}) {
// since currentTime is in seconds
final elapsed = (stopwatch.elapsedMilliseconds / 1000).round();
stopwatch.stop();
final metric = Metric(
name,
MetricType.gauge,
[
[currentTime - elapsed, currentTime - elapsed],
[currentTime, currentTime]
],
host: host,
interval: interval,
prefix: prefix,
tags: mergeTags(tags),
);
send(metric);
return metric;
}