HTTPTransactionTracer
public protocol HTTPTransactionTracer
Used to trace the execution of HTTPTransactions from beginning to end.
-
Called to notify the tracer that the given
HTTPTransactionis about to be executed.If this is called with a given
transactionID, it will (eventually) be balanced by a call todidComplete(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
transactionThe
HTTPTransactionbeing reported to the tracer.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer. -
Called after a
URLRequestfor 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
requestThe fully-configured
URLRequestas it will be issued.transactionThe
HTTPTransactionbeing reported to the tracer.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer. -
Called after a
URLRequesthas 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
requestThe
URLRequestas it was issued.transactionThe
HTTPTransactionbeing reported to the tracer.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer. -
Called after an
HTTPURLResponsehas been received in response to a priorURLRequestbeing 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
responseThe
HTTPURLResponsereceived in response torequest.requestThe
URLRequest.transactionThe
HTTPTransactionbeing reported to the tracer.metaAn
HTTPResponseMetadatainstance containing details about the HTTP response.dataA
Datainstance containing the body of the HTTP response, in unparsed binary form.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer. -
Called after the
HTTPURLResponsehas been successfully validated.Although response validation can be configured by supplying a custom
ResponseValidatorto anHTTPTransaction, 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
responseThe
HTTPURLResponsereceived in response torequest.requestThe
URLRequest.transactionThe
HTTPTransactionbeing reported to the tracer.metaAn
HTTPResponseMetadatainstance containing details about the HTTP response.dataA
Datainstance containing the body of the HTTP response, in unparsed binary form.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan 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
payloadThe
ResponseDataTypepayload extracted from the response.transactionThe
HTTPTransactionbeing reported to the tracer.metaAn
HTTPResponseMetadatainstance containing details about the HTTP response.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan 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.succeededResult.Declaration
Swift
func didValidate<T>(payload: HTTPTransaction<T>.ResponseDataType, for transaction: HTTPTransaction<T>, meta: HTTPResponseMetadata, id transactionID: UUID)Parameters
payloadThe validated
ResponseDataTypepayload.transactionThe
HTTPTransactionbeing reported to the tracer.metaAn
HTTPResponseMetadatainstance containing details about the HTTP response.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer. -
Called immediately before an executing transaction reports a final
Resultto itsCallbackfunction.This function will be eventually be called for every call to
willExecute(transaction:id:)having the sametransactionID.Declaration
Swift
func didComplete<T>(transaction: HTTPTransaction<T>, result: HTTPTransaction<T>.Result, meta: HTTPResponseMetadata?, id transactionID: UUID)Parameters
payloadThe validated
ResponseDataTypepayload.transactionThe
HTTPTransactionbeing reported to the tracer.metaAn
HTTPResponseMetadatainstance containing details about the HTTP response. Will benilif transaction execution did not get as far as receiving an HTTP response.transactionIDA unique identifier for this particular execution of
transaction. Astransactionexecutes a single time, thetransactionIDcan be used to correlate different calls to the tracer.
View on GitHub
HTTPTransactionTracer Protocol Reference