Breadcrumb.http constructor
Breadcrumb.http({})
Implementation
factory Breadcrumb.http({
required Uri url,
required String method,
int? statusCode,
String? reason,
Duration? requestDuration,
SentryLevel? level,
DateTime? timestamp,
// Size of the request body in bytes
int? requestBodySize,
// Size of the response body in bytes
int? responseBodySize,
String? httpQuery,
String? httpFragment,
}) {
// The timestamp is used as the request-end time, so we need to set it right
// now and not rely on the default constructor.
timestamp ??= getUtcDateTime();
return Breadcrumb(
type: 'http',
category: 'http',
level: level,
timestamp: timestamp,
data: {
'url': url.toString(),
'method': method,
if (statusCode != null) 'status_code': statusCode,
if (reason != null) 'reason': reason,
if (requestDuration != null) 'duration': requestDuration.toString(),
if (requestBodySize != null) 'request_body_size': requestBodySize,
if (responseBodySize != null) 'response_body_size': responseBodySize,
if (httpQuery != null) 'http.query': httpQuery,
if (httpFragment != null) 'http.fragment': httpFragment,
if (requestDuration != null)
'start_timestamp':
timestamp.millisecondsSinceEpoch - requestDuration.inMilliseconds,
if (requestDuration != null)
'end_timestamp': timestamp.millisecondsSinceEpoch,
},
);
}