complete method

Future<void> complete({
  1. required int statusCode,
  2. Map<String, String>? headers,
  3. Uint8List? bodyBytes,
  4. int? responseSizeBytes,
  5. String? contentType,
  6. int? durationMs,
  7. bool? responseTruncatedAtStorage,
})

Records a completed HTTP response. Safe and idempotent.

Implementation

Future<void> complete({
  required int statusCode,
  Map<String, String>? headers,
  Uint8List? bodyBytes,
  int? responseSizeBytes,
  String? contentType,
  int? durationMs,
  bool? responseTruncatedAtStorage,
}) async {
  if (_isSettled || _context == null) return;
  _isSettled = true;

  await guardCaptureAsync(() async {
    await collector.completeResponse(
      context: _context!,
      statusCode: statusCode,
      headers: headers,
      bodyBytes: bodyBytes,
      responseSizeBytes: responseSizeBytes,
      responseContentType: contentType,
      durationMs: durationMs,
      responseTruncatedAtStorage: responseTruncatedAtStorage,
    );
  });
}