Class MicrometerHttpClient
java.lang.Object
java.net.http.HttpClient
io.micrometer.java11.instrument.binder.jdk.MicrometerHttpClient
- All Implemented Interfaces:
AutoCloseable
Delegates to an
HttpClient
while instrumenting with Micrometer any HTTP calls
made. Example setup:
HttpClient observedClient = MicrometerHttpClient.instrumentationBuilder(HttpClient.newHttpClient(), meterRegistry).build();
Inspired by interceptable-http-client.- Since:
- 1.13.0
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.net.http.HttpClient
HttpClient.Builder, HttpClient.Redirect, HttpClient.Version
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionexecutor()
instrumentationBuilder
(HttpClient httpClient, io.micrometer.core.instrument.MeterRegistry meterRegistry) Builder for instrumentation ofHttpClient
.proxy()
<T> HttpResponse
<T> send
(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler) <T> CompletableFuture
<HttpResponse<T>> sendAsync
(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler) <T> CompletableFuture
<HttpResponse<T>> sendAsync
(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler, HttpResponse.PushPromiseHandler<T> pushPromiseHandler) version()
Methods inherited from class java.net.http.HttpClient
awaitTermination, close, isTerminated, newBuilder, newHttpClient, newWebSocketBuilder, shutdown, shutdownNow
-
Field Details
-
URI_PATTERN_HEADER
Header name for URI pattern.- See Also:
-
-
Method Details
-
instrumentationBuilder
public static MicrometerHttpClient.InstrumentationBuilder instrumentationBuilder(HttpClient httpClient, io.micrometer.core.instrument.MeterRegistry meterRegistry) Builder for instrumentation ofHttpClient
.- Parameters:
httpClient
- HttpClient to wrapmeterRegistry
- meter registry- Returns:
- builder
-
cookieHandler
- Specified by:
cookieHandler
in classHttpClient
-
connectTimeout
- Specified by:
connectTimeout
in classHttpClient
-
followRedirects
- Specified by:
followRedirects
in classHttpClient
-
proxy
- Specified by:
proxy
in classHttpClient
-
sslContext
- Specified by:
sslContext
in classHttpClient
-
sslParameters
- Specified by:
sslParameters
in classHttpClient
-
authenticator
- Specified by:
authenticator
in classHttpClient
-
version
- Specified by:
version
in classHttpClient
-
executor
- Specified by:
executor
in classHttpClient
-
send
public <T> HttpResponse<T> send(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler) throws IOException, InterruptedException - Specified by:
send
in classHttpClient
- Throws:
IOException
InterruptedException
-
sendAsync
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler) - Specified by:
sendAsync
in classHttpClient
-
sendAsync
public <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest httpRequest, HttpResponse.BodyHandler<T> bodyHandler, @Nullable HttpResponse.PushPromiseHandler<T> pushPromiseHandler) - Specified by:
sendAsync
in classHttpClient
-