HTTPTransactionTracer

public protocol HTTPTransactionTracer

Used to trace the execution of HTTPTransactions from beginning to end.

  • Called to notify the tracer that the given HTTPTransaction is about to be executed.

    If this is called with a given transactionID, it will (eventually) be balanced by a call to didComplete(transaction:result:meta:id). Additional trace functions may or may not be called depending on what happens with the transaction at runtime.

    Declaration

    Swift

    func willExecute<T>(transaction: HTTPTransaction<T>, id transactionID: UUID)

    Parameters

    transaction

    The HTTPTransaction being reported to the tracer.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after a URLRequest for the given transaction has been fully configured, and just before the request is about to be issued.

    Declaration

    Swift

    func didConfigure<T>(request: URLRequest, for transaction: HTTPTransaction<T>, id transactionID: UUID)

    Parameters

    request

    The fully-configured URLRequest as it will be issued.

    transaction

    The HTTPTransaction being reported to the tracer.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after a URLRequest has been issued, but before any sort of response has been received.

    Note that the transaction may complete prior to receiving an HTTP response if an error occurs before then. As a result, a call to this function may not necessarily be balanced by a call to didReceive(response:to:for:meta:data:id:).

    Declaration

    Swift

    func didIssue<T>(request: URLRequest, for transaction: HTTPTransaction<T>, id transactionID: UUID)

    Parameters

    request

    The URLRequest as it was issued.

    transaction

    The HTTPTransaction being reported to the tracer.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after an HTTPURLResponse has been received in response to a prior URLRequest being issued.

    Note that the response may contain an HTTP error code.

    Declaration

    Swift

    func didReceive<T>(response: HTTPURLResponse, to request: URLRequest, for transaction: HTTPTransaction<T>, meta: HTTPResponseMetadata, data: Data, id transactionID: UUID)

    Parameters

    response

    The HTTPURLResponse received in response to request.

    request

    The URLRequest.

    transaction

    The HTTPTransaction being reported to the tracer.

    meta

    An HTTPResponseMetadata instance containing details about the HTTP response.

    data

    A Data instance containing the body of the HTTP response, in unparsed binary form.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after the HTTPURLResponse has been successfully validated.

    Although response validation can be configured by supplying a custom ResponseValidator to an HTTPTransaction, the default implementation enforces that the response does not represent an HTTP error of some kind. In such cases, this function is called only when the HTTP response is known to be a non-error.

    Declaration

    Swift

    func didValidate<T>(response: HTTPURLResponse, to request: URLRequest, for transaction: HTTPTransaction<T>, meta: HTTPResponseMetadata, data: Data, id transactionID: UUID)

    Parameters

    response

    The HTTPURLResponse received in response to request.

    request

    The URLRequest.

    transaction

    The HTTPTransaction being reported to the tracer.

    meta

    An HTTPResponseMetadata instance containing details about the HTTP response.

    data

    A Data instance containing the body of the HTTP response, in unparsed binary form.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after the payload has been extracted from the raw binary data contained in the HTTP response body.

    This function is called before the payload is validated.

    Declaration

    Swift

    func didExtract<T>(payload: HTTPTransaction<T>.ResponseDataType, for transaction: HTTPTransaction<T>, meta: HTTPResponseMetadata, id transactionID: UUID)

    Parameters

    payload

    The ResponseDataType payload extracted from the response.

    transaction

    The HTTPTransaction being reported to the tracer.

    meta

    An HTTPResponseMetadata instance containing details about the HTTP response.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called after the response payload has been successfully validated.

    Payload validation is the last step performed by a successful transaction, so a call to this function ensures there will be a subsequent call to didComplete(transaction:result:meta:id:) with a .succeeded Result.

    Declaration

    Swift

    func didValidate<T>(payload: HTTPTransaction<T>.ResponseDataType, for transaction: HTTPTransaction<T>, meta: HTTPResponseMetadata, id transactionID: UUID)

    Parameters

    payload

    The validated ResponseDataType payload.

    transaction

    The HTTPTransaction being reported to the tracer.

    meta

    An HTTPResponseMetadata instance containing details about the HTTP response.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.

  • Called immediately before an executing transaction reports a final Result to its Callback function.

    This function will be eventually be called for every call to willExecute(transaction:id:) having the same transactionID.

    Declaration

    Swift

    func didComplete<T>(transaction: HTTPTransaction<T>, result: HTTPTransaction<T>.Result, meta: HTTPResponseMetadata?, id transactionID: UUID)

    Parameters

    payload

    The validated ResponseDataType payload.

    transaction

    The HTTPTransaction being reported to the tracer.

    meta

    An HTTPResponseMetadata instance containing details about the HTTP response. Will be nil if transaction execution did not get as far as receiving an HTTP response.

    transactionID

    A unique identifier for this particular execution of transaction. As transaction executes a single time, the transactionID can be used to correlate different calls to the tracer.