okhttp / okhttp3 / EventListener / <init>

<init>

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) -&gt; dnsEnd(call, domainName, inetAddressList).

Nesting is as follows

Request events are ordered:

requestHeaders -&gt; requestBody -&gt; responseHeaders -&gt; 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.