Class

NSURLSessionTaskTransactionMetrics

An object that encapsualtes the performance metrics collected by the URL Loading System during the execution of a session task.

Declaration

@interface NSURLSessionTaskTransactionMetrics : NSObject

Overview

Each NSURLSessionTaskTransactionMetrics object consists of a request and response property, corresponding to the request and response of the corresponding task. It also contains temporal metrics, starting with fetchStartDate and ending with responseEndDate, as well as other characteristics like networkProtocolName and resourceFetchType.

Understanding Temporal Metrics

Figure 1 shows the sequence of events for a URL session task, which correspond to the temporal metrics captured by NSURLSessionTaskTransactionMetrics.

Figure 1

Timeline of temporal metrics for a URL session task

Diagram showing the temporal metrics for a URL session task. When a task starts, it performs a DNS lookup and then starts a connection. If the connection is encrypted, the user agent starts a TLS security handshake to secure the connection. After the connection to the server is established, the user agent requests the specified resource, and receives a response.

For all metrics with a start and end date, if an aspect of the task was not completed, then its corresponding end date metric is nil. This can happen if name lookup begins, but the operation either times out, fails, or the client cancels the task before the name can be resolved. In this case, the domainLookupEndDate property is nil, along with all metrics for aspects that occurred afterwards.

Topics

Accessing Request and Response

request

The transaction request.

response

The transaction response.

Accessing Temporal Metrics

fetchStartDate

The time when the task started fetching the resource, from the server or locally.

domainLookupStartDate

The time immediately before the task started the name lookup for the resource.

domainLookupEndDate

The time after the name lookup was completed.

connectStartDate

The time immediately before the task started establishing a TCP connection to the server.

secureConnectionStartDate

The time immediately before the task started the TLS security handshake to secure the current connection.

secureConnectionEndDate

The time immediately after the security handshake completed.

connectEndDate

The time immediately after the task finished establishing the connection to the server.

requestStartDate

The time immediately before the task started requesting the resource, regardless of whether it is retrieved from the server or local resources.

requestEndDate

The time immediately after the task finished requesting the resource, regardless of whether it was retrieved from the server or local resources.

responseStartDate

The time immediately after the task received the first byte of the response from the server or from local resources.

responseEndDate

The time immediately after the task received the last byte of the resource.

Accessing Data Transfer Metrics

countOfRequestBodyBytesBeforeEncoding

The size of the upload body data, file, or stream, in bytes.

countOfRequestBodyBytesSent

The number of bytes transferred for the request body.

countOfRequestHeaderBytesSent

The number of bytes transferred for the request header.

countOfResponseBodyBytesAfterDecoding

The size of data delivered to your delegate or completion handler.

countOfResponseBodyBytesReceived

The number of bytes transferred for the response body.

countOfResponseHeaderBytesReceived

The number of bytes transferred for the response header.

Accessing Transaction Characteristics

networkProtocolName

The network protocol used to fetch the resource.

remoteAddress

The IP address string of the remote interface for the connection.

remotePort

The port number of the remote interface for the connection.

localAddress

The IP address string of the local interface for the connection.

localPort

The port number of the local interface for the connection.

negotiatedTLSCipherSuite

The TLS cipher suite the task negotiated with the endpoint for the connection.

negotiatedTLSProtocolVersion

The TLS protocol version the task negotiated with the endpoint for the connection.

cellular

A Boolean value that indicates whether the connection operates over a cellular interface.

expensive

A Boolean value that indicates whether the connection operates over an expensive interface.

constrained

A Boolean value that indicates whether the connection operates over an interface marked as constrained.

proxyConnection

A Boolean value that indicastes whether the task used a proxy connection to fetch the resource.

reusedConnection

A Boolean value that indicates whether the task used a persistent connection to fetch the resource.

multipath

A Boolean value that indicates whether the connection uses a successfully negotiated multipath protocol.

resourceFetchType

A value that indicates whether the resource was loaded, pushed, or retrieved from the local cache.

NSURLSessionTaskMetricsResourceFetchType

The manner in which a resource is fetched.

Creating Transaction Metrics

- init

Creates a transaction metrics instance.

Deprecated
+ new

Creates a new transaction metrics instance.

Deprecated

Relationships

Inherits From

See Also

Accessing Task Metrics

transactionMetrics

An array of metrics for each individual request-response transaction made during the execution of the task.

taskInterval

The time interval between when a task is instantiated and when the task is completed.

redirectCount

The number of redirects that occurred during the execution of the task.