Class MicrometerHttpRequestExecutor

java.lang.Object
org.apache.hc.core5.http.impl.io.HttpRequestExecutor
io.micrometer.core.instrument.binder.httpcomponents.hc5.MicrometerHttpRequestExecutor

public class MicrometerHttpRequestExecutor extends org.apache.hc.core5.http.impl.io.HttpRequestExecutor
This instruments the execution of every request that goes through an HttpClient on which it is configured. It must be registered as request executor when creating the HttpClient instance. For example:
     HttpClientBuilder.create()
         .setRequestExecutor(MicrometerHttpRequestExecutor
                 .builder(meterRegistry)
                 .build())
         .build();
 
Since:
1.11.0
  • Method Details

    • builder

      public static MicrometerHttpRequestExecutor.Builder builder(MeterRegistry registry)
      Use this method to create an instance of MicrometerHttpRequestExecutor.
      Parameters:
      registry - The registry to register the metrics to.
      Returns:
      An instance of the builder, which allows further configuration of the request executor.
    • execute

      public org.apache.hc.core5.http.ClassicHttpResponse execute(org.apache.hc.core5.http.ClassicHttpRequest request, org.apache.hc.core5.http.io.HttpClientConnection conn, org.apache.hc.core5.http.protocol.HttpContext context) throws IOException, org.apache.hc.core5.http.HttpException
      Overrides:
      execute in class org.apache.hc.core5.http.impl.io.HttpRequestExecutor
      Throws:
      IOException
      org.apache.hc.core5.http.HttpException