flush method
Forwards all items in the buffer onto next before also flushing next.
Implementation
@override
Future<void> flush() async {
if (_buffer.isNotEmpty) {
final bufferClone = List<ContextualTelemetryItem>.from(_buffer);
_buffer.clear();
final next = this.next;
if (next != null) {
next.process(
contextualTelemetryItems: bufferClone,
);
await next.flush();
}
}
// It's vital to call cancel here in case flush was called pro-actively prior to shutting down the application.
// If the timer is not canceled, it will cause the process to wait for it to fire before it exits.
_flushTimer?.cancel();
_flushTimer = null;
}