FinishedRequestTimings


class FinishedRequestTimings
kotlin.Any
   ↳ android.net.http.FinishedRequestTimings

Metrics collected for a single request. Most of these metrics are timestamps for events during the lifetime of the BidirectionalStream or UrlRequest, which can be used to build a detailed timeline for investigating performance.

Timestamps are derived from a monotonic clock.

Start times are reported as the time when a request started waiting for an event, not when the event actually started. If a metric is not available, including cases when a request finished before reaching that stage, start and end times will be null. If no time was spent blocking on an event, start and end will be the same time.

A metric can be null if it's unavailable (e.g. SSL metrics are null if the host name was not resolved).

Summary

Public methods
Instant?

Returns the timestamp for when the connection establishment ended.

Instant?

Returns the timestamp for when the connection attempt began.

Instant?

Returns the timestamp when the DNS lookup finished.

Instant?

Returns the timestamp when DNS lookup started.

Long

Returns total bytes received.

Instant?

Returns the timestamp when the request finished.

Instant?

Returns the timestamp when the request started.

Instant?

Returns the timestamp when sending the request finished.

Instant?

Returns the timestamp when sending the request started.

Long

Returns total bytes sent.

Instant?

Returns the timestamp when TLS handshake finished.

Instant?

Returns the timestamp when TLS handshake started.

Boolean

Returns whether the socket was reused from a previous request.

Public methods

getConnectingEnd

fun getConnectingEnd(): Instant?

Returns the timestamp for when the connection establishment ended. If the connection used by the request is already active, this returns null.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing when the connection establishment finished. If using HTTPS, TLS handshake is completed. In some cases, such as 0-RTT, the stack may start sending data before connection establishment is considered complete; in such cases, this timestamp may occur after getSendingStart().

getConnectingStart

fun getConnectingStart(): Instant?

Returns the timestamp for when the connection attempt began. If a connection is already active, this returns null.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing when the connection establishment started, or null.

getDnsEnd

fun getDnsEnd(): Instant?

Returns the timestamp when the DNS lookup finished.

This value is null if no DNS lookup was required, such as when the request reuses an existing connection. If a lookup was attempted, this value will be non-null, regardless of whether the lookup succeeded (via network or cache) or failed.

See RequestFinishedTimings for more detailed timing information.

Return
Instant? the java.time.Instant when the DNS lookup completed, or null if no lookup was performed.

getDnsStart

fun getDnsStart(): Instant?

Returns the timestamp when DNS lookup started. If a connection is already active, this returns null.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing when the DNS lookup started, or null.

getReceivedByteCount

fun getReceivedByteCount(): Long

Returns total bytes received.

Return
Long Value is 0 or greater

getRequestEnd

fun getRequestEnd(): Instant?

Returns the timestamp when the request finished.

This value is null if the request failed to start, as documented in getRequestStart(). If the request started successfully, this reflects the time it reached a terminal state, including success, failure, or cancellation.

See RequestFinishedTimings for more information.

Return
Instant? the java.time.Instant when the request finished, or null if the request never started.

getRequestStart

fun getRequestStart(): Instant?

Returns the timestamp when the request started.

This value is null if the request fails initial validation checks during UrlRequest.start() or org.chromium.net.BidirectionalStream#start() (for example, if an invalid header is provided).

See RequestFinishedTimings for more information.

Return
Instant? the java.time.Instant when the request began, or null if the request failed before starting.

getSendingEnd

fun getSendingEnd(): Instant?

Returns the timestamp when sending the request finished.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing the end of sending HTTP request (including the body).
This value may be null.

getSendingStart

fun getSendingStart(): Instant?

Returns the timestamp when sending the request started.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing the beginning of sending HTTP request headers.
This value may be null.

getSentByteCount

fun getSentByteCount(): Long

Returns total bytes sent.

Return
Long Value is 0 or greater

getTlsHandshakeEnd

fun getTlsHandshakeEnd(): Instant?

Returns the timestamp when TLS handshake finished. This will always be equal to #getConnectEnd.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing when the TLS establishment finished.
This value may be null.

getTlsHandshakeStart

fun getTlsHandshakeStart(): Instant?

Returns the timestamp when TLS handshake started.

See the documentation on RequestFinishedTimings for more information.

Return
Instant? java.time.Instant representing when the TLS handshake has started. This will be later than getConnectStart. In cases where the TLS handshake is started immediately (e.g. QUIC), this may be equal to getConnectStart.
This value may be null.

wasSocketReused

fun wasSocketReused(): Boolean

Returns whether the socket was reused from a previous request. Cases where this can happen include: reusing an idle socket that was used to complete a previous HTTP/1 request; multiplexing streams on a single HTTP/2 or QUIC connection.

Note that when a socket is reused, then DNS, connect and SSL timings are meaningless and undefined, as the request did not go through any of these stages.

Return
Boolean true if a socket has been reused.