FinishedRequestTimings


public final class FinishedRequestTimings
extends Object

java.lang.Object
   ↳ 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 getConnectingEnd()

Returns the timestamp for when the connection establishment ended.

Instant getConnectingStart()

Returns the timestamp for when the connection attempt began.

Instant getDnsEnd()

Returns the timestamp when the DNS lookup finished.

Instant getDnsStart()

Returns the timestamp when DNS lookup started.

long getReceivedByteCount()

Returns total bytes received.

Instant getRequestEnd()

Returns the timestamp when the request finished.

Instant getRequestStart()

Returns the timestamp when the request started.

Instant getSendingEnd()

Returns the timestamp when sending the request finished.

Instant getSendingStart()

Returns the timestamp when sending the request started.

long getSentByteCount()

Returns total bytes sent.

Instant getTlsHandshakeEnd()

Returns the timestamp when TLS handshake finished.

Instant getTlsHandshakeStart()

Returns the timestamp when TLS handshake started.

boolean wasSocketReused()

Returns whether the socket was reused from a previous request.

Inherited methods

Public methods

getConnectingEnd

public Instant getConnectingEnd ()

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 ERROR(/RequestFinishedTimings) for more information.

Returns
Instant 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

public Instant getConnectingStart ()

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

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant Instant representing when the connection establishment started, or null.

getDnsEnd

public Instant getDnsEnd ()

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 ERROR(/RequestFinishedTimings) for more detailed timing information.

Returns
Instant the Instant when the DNS lookup completed, or null if no lookup was performed.

getDnsStart

public Instant getDnsStart ()

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

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant Instant representing when the DNS lookup started, or null.

getReceivedByteCount

public long getReceivedByteCount ()

Returns total bytes received.

Returns
long Value is 0 or greater

getRequestEnd

public Instant getRequestEnd ()

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 ERROR(/RequestFinishedTimings) for more information.

Returns
Instant the Instant when the request finished, or null if the request never started.

getRequestStart

public Instant getRequestStart ()

Returns the timestamp when the request started.

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

See ERROR(/RequestFinishedTimings) for more information.

Returns
Instant the Instant when the request began, or null if the request failed before starting.

getSendingEnd

public Instant getSendingEnd ()

Returns the timestamp when sending the request finished.

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant Instant representing the end of sending HTTP request (including the body).
This value may be null.

getSendingStart

public Instant getSendingStart ()

Returns the timestamp when sending the request started.

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant Instant representing the beginning of sending HTTP request headers.
This value may be null.

getSentByteCount

public long getSentByteCount ()

Returns total bytes sent.

Returns
long Value is 0 or greater

getTlsHandshakeEnd

public Instant getTlsHandshakeEnd ()

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

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant Instant representing when the TLS establishment finished.
This value may be null.

getTlsHandshakeStart

public Instant getTlsHandshakeStart ()

Returns the timestamp when TLS handshake started.

See the documentation on ERROR(/RequestFinishedTimings) for more information.

Returns
Instant 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

public boolean wasSocketReused ()

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.

Returns
boolean true if a socket has been reused.