flushOtlpTracing static method
Best-effort delivery of queued HTTP CLIENT spans from the native encrypted queue.
Flutter has no span exporter of its own: Dart only propagates trace context and
hands each HTTP record to the Android or iOS SDK, whose exporter builds, queues and
sends the span. This call waits at most timeout (capped at maxOtlpFlushTimeout)
and returns true only when the native SDK confirms delivery; false means timeout,
pending delivery (including a batch waiting for its scheduled retry) or spans dropped
since the previous flush. Throws a
PlatformException with code OTLP_SDK_UNAVAILABLE when the native SDK in the app
has no OTLP exporter.
Implementation
static Future<bool> flushOtlpTracing({
Duration timeout = const Duration(seconds: 2),
}) async {
final timeoutMillis = timeout.inMilliseconds.clamp(
0,
maxOtlpFlushTimeout.inMilliseconds,
);
return await _channel.invokeMethod<bool>(MethodNames.flushOtlpTracing, {
'timeoutMillis': timeoutMillis,
}) ??
false;
}