exportTrace method

int exportTrace(
  1. String traceJson
)

Exports a single trace JSON payload.

Implementation

int exportTrace(String traceJson) {
  if (!_initialized) {
    throw Exception('Not initialized');
  }
  if (!_symbolsAvailable) {
    return -1;
  }

  final bytes = utf8.encode(traceJson);
  final ptr = malloc<ffi.Uint8>(bytes.length);
  try {
    ptr.asTypedList(bytes.length).setAll(0, bytes);
    final result = _otelExportTracePtr!
        .asFunction<int Function(ffi.Pointer<ffi.Uint8>, int)>()(
      ptr,
      bytes.length,
    );
    if (result != 0) {
      _captureNativeError();
    }
    return _legacySuccessCode(result);
  } finally {
    malloc.free(ptr);
  }
}