MCPcopy Index your code
hub / github.com/OpenFeign/feign / MeteredClient

Class MeteredClient

micrometer/src/main/java/feign/micrometer/MeteredClient.java:28–71  ·  view source on GitHub ↗

Wrap feign Client with metrics.

Source from the content-addressed store, hash-verified

26
27/** Wrap feign {@link Client} with metrics. */
28public class MeteredClient extends BaseMeteredClient implements Client {
29
30 private final Client client;
31
32 public MeteredClient(Client client, MeterRegistry meterRegistry) {
33 this(client, meterRegistry, new FeignMetricName(Client.class), new FeignMetricTagResolver());
34 }
35
36 public MeteredClient(
37 Client client,
38 MeterRegistry meterRegistry,
39 MetricName metricName,
40 MetricTagResolver metricTagResolver) {
41 super(meterRegistry, metricName, metricTagResolver);
42 this.client = client;
43 }
44
45 @Override
46 public Response execute(Request request, Options options) throws IOException {
47 final Timer.Sample sample = Timer.start(meterRegistry);
48 Timer timer = null;
49 try {
50 final Response response = client.execute(request, options);
51 countResponseCode(request, response, options, response.status(), null);
52 timer = createTimer(request, response, options, null);
53 return response;
54 } catch (FeignException e) {
55 timer = createTimer(request, null, options, e);
56 countResponseCode(request, null, options, e.status(), e);
57 throw e;
58 } catch (IOException | RuntimeException e) {
59 timer = createTimer(request, null, options, e);
60 throw e;
61 } catch (Exception e) {
62 timer = createTimer(request, null, options, e);
63 throw new IOException(e);
64 } finally {
65 if (timer == null) {
66 timer = createTimer(request, null, options, null);
67 }
68 sample.stop(timer);
69 }
70 }
71}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected