span<T> static method
Runs body and reports it as a timed event on channel — duration in
fractional milliseconds under ms, the error under error if it threw.
The error is rethrown; this observes, it never swallows.
Implementation
static Future<T> span<T>(
String channel,
Map<String, Object?> payload,
Future<T> Function() body,
) async {
var watch = Stopwatch()..start();
Object? error;
try {
return await body();
} catch (e) {
error = e;
rethrow;
} finally {
_spanEvent(channel, payload, watch, error);
}
}