diff --git a/dropwizard-metrics4/src/main/java/feign/metrics4/BaseMeteredClient.java b/dropwizard-metrics4/src/main/java/feign/metrics4/BaseMeteredClient.java index 82810801c..a29e36c13 100644 --- a/dropwizard-metrics4/src/main/java/feign/metrics4/BaseMeteredClient.java +++ b/dropwizard-metrics4/src/main/java/feign/metrics4/BaseMeteredClient.java @@ -53,6 +53,8 @@ protected void recordSuccess(RequestTemplate template, Response response) { response.status() / 100 + "xx", "http_status", String.valueOf(response.status()), + "http_method", + template.methodMetadata().template().method(), "uri", template.methodMetadata().template().path()), metricSuppliers.meters()) @@ -72,6 +74,8 @@ protected void recordFailure(RequestTemplate template, FeignException e) { e.status() / 100 + "xx", "http_status", String.valueOf(e.status()), + "http_method", + template.methodMetadata().template().method(), "uri", template.methodMetadata().template().path()), metricSuppliers.meters()) diff --git a/dropwizard-metrics5/src/main/java/feign/metrics5/BaseMeteredClient.java b/dropwizard-metrics5/src/main/java/feign/metrics5/BaseMeteredClient.java index 24796cd14..10d015c24 100644 --- a/dropwizard-metrics5/src/main/java/feign/metrics5/BaseMeteredClient.java +++ b/dropwizard-metrics5/src/main/java/feign/metrics5/BaseMeteredClient.java @@ -52,6 +52,7 @@ protected void recordSuccess(RequestTemplate template, Response response) { httpResponseCode(template) .tagged("http_status", String.valueOf(response.status())) .tagged("status_group", response.status() / 100 + "xx") + .tagged("http_method", template.methodMetadata().template().method()) .tagged("uri", template.methodMetadata().template().path())) .inc(); } @@ -65,6 +66,7 @@ protected void recordFailure(RequestTemplate template, FeignException e) { ExceptionUtils.getRootCause(e).getClass().getSimpleName()) .tagged("http_status", String.valueOf(e.status())) .tagged("status_group", e.status() / 100 + "xx") + .tagged("http_method", template.methodMetadata().template().method()) .tagged("uri", template.methodMetadata().template().path())) .inc(); } diff --git a/micrometer/src/main/java/feign/micrometer/BaseMeteredClient.java b/micrometer/src/main/java/feign/micrometer/BaseMeteredClient.java index ed35b091d..e4cbe6e49 100644 --- a/micrometer/src/main/java/feign/micrometer/BaseMeteredClient.java +++ b/micrometer/src/main/java/feign/micrometer/BaseMeteredClient.java @@ -53,6 +53,7 @@ protected void countResponseCode( e, Tag.of("http_status", String.valueOf(responseStatus)), Tag.of("status_group", responseStatus / 100 + "xx"), + Tag.of("http_method", template.methodMetadata().template().method()), Tag.of("uri", template.methodMetadata().template().path())) .and(extraTags); meterRegistry.counter(metricName.name("http_response_code"), allTags).increment(); diff --git a/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java b/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java index 9245a0ba6..eb34bfaa4 100644 --- a/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java +++ b/micrometer/src/test/java/feign/micrometer/AbstractMetricsTestBase.java @@ -45,12 +45,14 @@ public interface SimpleSource { String get(String body); } + public interface CompletableSource { @RequestLine("GET /get") CompletableFuture get(String body); } + protected MR metricsRegistry; @Before @@ -169,7 +171,8 @@ public void clientPropagatesUncheckedException() { } assertThat( - getMetric("http_response_code", "http_status", "404", "status_group", "4xx"), + getMetric("http_response_code", "http_status", "404", "status_group", "4xx", + "http_method", "GET"), notNullValue()); }