# RequestFinishedInfo.Metrics


```
public abstract class RequestFinishedInfo.Metrics
```

<br />

*** ** * ** ***

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

Events happen in this order:

1. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getRequestStart()`
2. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsStart()`
3. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsEnd()`
4. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectStart()`
5. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSslStart()`
6. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSslEnd()`
7. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectEnd()`
8. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSendingStart()`
9. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSendingEnd()`
10. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getResponseStart()`
11. `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getRequestEnd()`

Start times are reported as the time when a request started blocking on event, not when the event actually occurred, with the exception of push start and end. If a metric is not meaningful or 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.

If the system clock is adjusted during the request, some of the `https://developer.android.com/reference/java/util/Date.html` values might not match it. Timestamps are recorded using a clock that is guaranteed not to run backwards. All timestamps are correct relative to the system clock at the time of request start, and taking the difference between two timestamps will give the correct difference between the events. In order to preserve this property, timestamps for events other than request start are not guaranteed to match the system clock at the times they represent.

Most timing metrics are taken from [LoadTimingInfo](https://cs.chromium.org/chromium/src/net/base/load_timing_info.h), which holds the information for [](http://w3c.github.io/navigation-timing/) and [](https://www.w3.org/TR/resource-timing/).

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#Metrics()()` |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectEnd()()` Returns time when connection establishment finished. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectStart()()` Returns time when connection establishment started. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsEnd()()` Returns time when DNS lookup finished. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsStart()()` Returns time when DNS lookup started. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getPushEnd()()` Returns time when last byte of HTTP/2 server push was received. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getPushStart()()` Returns time when first byte of HTTP/2 server push was received. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/lang/Long.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getReceivedByteCount()()` Returns total bytes received over the network transport layer, or `null` if not collected. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getRequestEnd()()` Returns time when the request finished. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getRequestStart()()` Returns time when the request started. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getResponseStart()()` Returns time when the end of the response headers was received. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSendingEnd()()` Returns time when sending the request finished. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSendingStart()()` Returns time when sending the request started. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/lang/Long.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSentByteCount()()` Returns total bytes sent over the network transport layer, or `null` if not collected. |
| `abstract boolean` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()()` Returns whether the socket was reused from a previous request. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSslEnd()()` Returns time when SSL handshake finished. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSslStart()()` Returns time when SSL handshake started. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/lang/Long.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getTotalTimeMs()()` Returns milliseconds between request initiation and finish, including a failure or cancellation, or `null` if not collected. |
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/lang/Long.html` | `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getTtfbMs()()` Returns milliseconds between request initiation and first byte of response headers, or `null` if not collected. |

## Public constructors

### Metrics

```
public Metrics()
```

## Public methods

### getConnectEnd

```
public abstract @Nullable Date getConnectEnd()
```

Returns time when connection establishment finished.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when connection establishment finished, after TCP connection is established and, if using HTTPS, SSL handshake is completed. For QUIC 0-RTT, this represents the time of handshake confirmation and might happen later than `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSendingStart()`. `null` if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getConnectStart

```
public abstract @Nullable Date getConnectStart()
```

Returns time when connection establishment started.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when connection establishment started, typically when DNS resolution finishes. `null` if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getDnsEnd

```
public abstract @Nullable Date getDnsEnd()
```

Returns time when DNS lookup finished. This and `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsStart()` will return non-null values regardless of whether the result came from a DNS server or the local cache.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when DNS lookup finished. `null` if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getDnsStart

```
public abstract @Nullable Date getDnsStart()
```

Returns time when DNS lookup started. This and `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getDnsEnd()` will return non-null values regardless of whether the result came from a DNS server or the local cache.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when DNS lookup started. `null` if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getPushEnd

```
public abstract @Nullable Date getPushEnd()
```

Returns time when last byte of HTTP/2 server push was received.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when the last byte of an HTTP/2 server push was received. `null` if server push is not used. |

### getPushStart

```
public abstract @Nullable Date getPushStart()
```

Returns time when first byte of HTTP/2 server push was received.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when the first byte of an HTTP/2 server push was received. `null` if server push is not used. |

### getReceivedByteCount

```
public abstract @Nullable Long getReceivedByteCount()
```

Returns total bytes received over the network transport layer, or `null` if not collected. Number of bytes does not include any previous redirects.

### getRequestEnd

```
public abstract @Nullable Date getRequestEnd()
```

Returns time when the request finished.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when the request finished. |

### getRequestStart

```
public abstract @Nullable Date getRequestStart()
```

Returns time when the request started.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when the native request actually started. This timestamp will match the system clock at the time it represents. |

### getResponseStart

```
public abstract @Nullable Date getResponseStart()
```

Returns time when the end of the response headers was received.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when the end of the response headers was received. |

### getSendingEnd

```
public abstract @Nullable Date getSendingEnd()
```

Returns time when sending the request finished.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when sending HTTP request body finished. (Sending request body happens after sending request headers.) |

### getSendingStart

```
public abstract @Nullable Date getSendingStart()
```

Returns time when sending the request started.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when sending HTTP request headers started. |

### getSentByteCount

```
public abstract @Nullable Long getSentByteCount()
```

Returns total bytes sent over the network transport layer, or `null` if not collected.

### getSocketReused

```
public abstract boolean getSocketReused()
```

Returns whether the socket was reused from a previous request. In HTTP/2 or QUIC, if streams are multiplexed in a single connection, returns `true` for all streams after the first.

| Returns |
|---|---|
| `boolean` | whether this request reused a socket from a previous request. When `true`, DNS, connection, and SSL times will be `null`. |

### getSslEnd

```
public abstract @Nullable Date getSslEnd()
```

Returns time when SSL handshake finished. For QUIC, this will be the same time as `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectEnd()`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when SSL handshake finished. `null` if SSL is not used or if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getSslStart

```
public abstract @Nullable Date getSslStart()
```

Returns time when SSL handshake started. For QUIC, this will be the same time as `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getConnectStart()`.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable.html https://developer.android.com/reference/java/util/Date.html` | `https://developer.android.com/reference/java/util/Date.html` representing when SSL handshake started. `null` if SSL is not used or if the socket was reused (see `https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Metrics#getSocketReused()`). |

### getTotalTimeMs

```
public abstract @Nullable Long getTotalTimeMs()
```

Returns milliseconds between request initiation and finish, including a failure or cancellation, or `null` if not collected. TODO(mgersh): Remove once new API works http://crbug.com/629194

### getTtfbMs

```
public abstract @Nullable Long getTtfbMs()
```

Returns milliseconds between request initiation and first byte of response headers, or `null` if not collected. TODO(mgersh): Remove once new API works http://crbug.com/629194