prepareBatchBody method
Prepares the batch body bytes for sending.
Override this for custom serialization (e.g., gzip compression). The default implementation JSON-encodes the batch.
Returns a record with body bytes and optional extra headers.
Implementation
@override
Future<({List<int> body, Map<String, String> extraHeaders})> prepareBatchBody(
List<Map<String, dynamic>> batch,
) async {
if (useIsolate) {
try {
final prepared = await isolateManager.prepareBatch(
batch: batch,
compress: false, // New Relic doesn't use compression
);
final body = utf8.encode(
utf8.decode((prepared['body'] as List).cast<int>()),
);
return (body: body, extraHeaders: <String, String>{});
} catch (_) {
// Fallback to direct processing
}
}
return (
body: utf8.encode(jsonEncode(batch)),
extraHeaders: <String, String>{},
);
}