abstract class EventListener
Listener for metrics events. Extend this class to monitor the quantity, size, and duration of your application's HTTP calls.
All start/connect/acquire events will eventually receive a matching end/release event, either successful (non-null parameters), or failed (non-null throwable). The first common parameters of each event pair are used to link the event in case of concurrent or repeated events e.g. dnsStart(call, domainName) -> dnsEnd(call, domainName, inetAddressList).
Nesting is as follows
Request events are ordered:
requestHeaders -> requestBody -> responseHeaders -> responseBody
Since connections may be reused, the dns and connect events may not be present for a call, or may be repeated in case of failure retries, even concurrently in case of happy eyeballs type scenarios. A redirect cross domain, or to use https may cause additional connection and request events.
All event methods must execute fast, without external locking, cannot throw exceptions, attempt to mutate the event parameters, or be re-entrant back into the client. Any IO - writing to files or network should be done asynchronously.
interface Factory |
EventListener()
Listener for metrics events. Extend this class to monitor the quantity, size, and duration of your application's HTTP calls. |
open fun callEnd(call: Call): Unit
Invoked immediately after a call has completely ended. This includes delayed consumption of response body by the caller. |
|
open fun callFailed(call: Call, ioe: IOException): Unit
Invoked when a call fails permanently. |
|
open fun callStart(call: Call): Unit
Invoked as soon as a call is enqueued or executed by a client. In case of thread or stream limits, this call may be executed well before processing the request is able to begin. |
|
open fun connectEnd(call: Call, inetSocketAddress: InetSocketAddress, proxy: Proxy, protocol: Protocol?): Unit
Invoked immediately after a socket connection was attempted. |
|
open fun connectFailed(call: Call, inetSocketAddress: InetSocketAddress, proxy: Proxy, protocol: Protocol?, ioe: IOException): Unit
Invoked when a connection attempt fails. This failure is not terminal if further routes are available and failure recovery is enabled. |
|
open fun connectionAcquired(call: Call, connection: Connection): Unit
Invoked after a connection has been acquired for the |
|
open fun connectionReleased(call: Call, connection: Connection): Unit
Invoked after a connection has been released for the |
|
open fun connectStart(call: Call, inetSocketAddress: InetSocketAddress, proxy: Proxy): Unit
Invoked just prior to initiating a socket connection. |
|
open fun dnsEnd(call: Call, domainName: String, inetAddressList: List<InetAddress>): Unit
Invoked immediately after a DNS lookup. |
|
open fun dnsStart(call: Call, domainName: String): Unit
Invoked just prior to a DNS lookup. See Dns.lookup. |
|
open fun requestBodyEnd(call: Call, byteCount: Long): Unit
Invoked immediately after sending a request body. |
|
open fun requestBodyStart(call: Call): Unit
Invoked just prior to sending a request body. Will only be invoked for request allowing and having a request body to send. |
|
open fun requestFailed(call: Call, ioe: IOException): Unit
Invoked when a request fails to be written. |
|
open fun requestHeadersEnd(call: Call, request: Request): Unit
Invoked immediately after sending request headers. |
|
open fun requestHeadersStart(call: Call): Unit
Invoked just prior to sending request headers. |
|
open fun responseBodyEnd(call: Call, byteCount: Long): Unit
Invoked immediately after receiving a response body and completing reading it. |
|
open fun responseBodyStart(call: Call): Unit
Invoked just prior to receiving the response body. |
|
open fun responseFailed(call: Call, ioe: IOException): Unit
Invoked when a response fails to be read. |
|
open fun responseHeadersEnd(call: Call, response: Response): Unit
Invoked immediately after receiving response headers. |
|
open fun responseHeadersStart(call: Call): Unit
Invoked just prior to receiving response headers. |
|
open fun secureConnectEnd(call: Call, handshake: Handshake?): Unit
Invoked immediately after a TLS connection was attempted. |
|
open fun secureConnectStart(call: Call): Unit
Invoked just prior to initiating a TLS connection. |
val NONE: EventListener |