Class

NSURLSessionTaskTransactionMetrics

An object encapsulating the performance metrics collected 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

Creating Transaction Metrics

- init

Creates a transaction metrics instance.

Deprecated

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 Transaction Characteristics

networkProtocolName

The network protocol used to fetch the resource.

proxyConnection

A Boolean value indicating whether a proxy connection was used to fetch the resource.

reusedConnection

A Boolean value indicating whether a persistent connection was used to fetch the resource.

resourceFetchType

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

NSURLSessionTaskMetricsResourceFetchType

The manner in which a resource is fetched.

Type Methods

+ newDeprecated

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software