Class OkHttpMetricsEventListener
java.lang.Object
okhttp3.EventListener
io.micrometer.core.instrument.binder.okhttp3.OkHttpMetricsEventListener
@NonNullApi @NonNullFields public class OkHttpMetricsEventListener extends okhttp3.EventListener
EventListener for collecting metrics from OkHttpClient.
uri tag is usually limited to URI patterns to mitigate tag cardinality explosion but OkHttpClient
doesn't provide URI patterns. We provide "URI_PATTERN" header to support
uri tag or you can configure a URI mapper to provide your own tag
values for uri tag.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOkHttpMetricsEventListener.BuilderNested classes/interfaces inherited from class okhttp3.EventListener
okhttp3.EventListener.Companion, okhttp3.EventListener.Factory -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringURI_PATTERNHeader name for URI patterns which will be used for tag values.Fields inherited from class okhttp3.EventListener
Companion, NONE -
Constructor Summary
Constructors Modifier Constructor Description protectedOkHttpMetricsEventListener(MeterRegistry registry, java.lang.String requestsMetricName, java.util.function.Function<okhttp3.Request,java.lang.String> urlMapper, java.lang.Iterable<Tag> extraTags, java.lang.Iterable<java.util.function.BiFunction<okhttp3.Request,okhttp3.Response,Tag>> contextSpecificTags) -
Method Summary
Modifier and Type Method Description static OkHttpMetricsEventListener.Builderbuilder(MeterRegistry registry, java.lang.String name)voidcallEnd(okhttp3.Call call)voidcallFailed(okhttp3.Call call, java.io.IOException e)voidcallStart(okhttp3.Call call)voidresponseHeadersEnd(okhttp3.Call call, okhttp3.Response response)Methods inherited from class okhttp3.EventListener
cacheConditionalHit, cacheHit, cacheMiss, canceled, connectEnd, connectFailed, connectionAcquired, connectionReleased, connectStart, dnsEnd, dnsStart, proxySelectEnd, proxySelectStart, requestBodyEnd, requestBodyStart, requestFailed, requestHeadersEnd, requestHeadersStart, responseBodyEnd, responseBodyStart, responseFailed, responseHeadersStart, satisfactionFailure, secureConnectEnd, secureConnectStartMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
URI_PATTERN
public static final java.lang.String URI_PATTERNHeader name for URI patterns which will be used for tag values.- See Also:
- Constant Field Values
-
-
Constructor Details
-
OkHttpMetricsEventListener
protected OkHttpMetricsEventListener(MeterRegistry registry, java.lang.String requestsMetricName, java.util.function.Function<okhttp3.Request,java.lang.String> urlMapper, java.lang.Iterable<Tag> extraTags, java.lang.Iterable<java.util.function.BiFunction<okhttp3.Request,okhttp3.Response,Tag>> contextSpecificTags)
-
-
Method Details
-
builder
public static OkHttpMetricsEventListener.Builder builder(MeterRegistry registry, java.lang.String name) -
callStart
public void callStart(okhttp3.Call call)- Overrides:
callStartin classokhttp3.EventListener
-
callFailed
public void callFailed(okhttp3.Call call, java.io.IOException e)- Overrides:
callFailedin classokhttp3.EventListener
-
callEnd
public void callEnd(okhttp3.Call call)- Overrides:
callEndin classokhttp3.EventListener
-
responseHeadersEnd
public void responseHeadersEnd(okhttp3.Call call, okhttp3.Response response)- Overrides:
responseHeadersEndin classokhttp3.EventListener
-