Skip to content

Commit 8d90874

Browse files
committed
Set request & response content length on request span
1 parent 85dcc15 commit 8d90874

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sources/AsyncHTTPClient/HTTPClient.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ public class HTTPClient {
394394
span.attributes.http.scheme = request.scheme
395395
span.attributes.http.target = request.uri
396396
span.attributes.http.host = request.host
397+
if let requestContentLength = request.body?.length {
398+
span.attributes.http.requestContentLength = requestContentLength
399+
}
397400

398401
// TODO: net.peer.ip / Not required, but recommended
399402

@@ -512,6 +515,7 @@ public class HTTPClient {
512515
if case let .success((_, response)) = result, let httpResponse = response as? HTTPClient.Response {
513516
span.attributes.http.statusCode = Int(httpResponse.status.code)
514517
span.attributes.http.statusText = httpResponse.status.reasonPhrase
518+
span.attributes.http.responseContentLength = httpResponse.body?.readableBytes ?? 0
515519
}
516520
span.end()
517521
setupComplete.succeed(())

0 commit comments

Comments
 (0)