Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add http_method tag to micrometer metrics #1968

Merged
merged 7 commits into from
Mar 17, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public interface SimpleSource {
String get(String body);
}


public interface CompletableSource {

@RequestLine("GET /get")
CompletableFuture<String> get(String body);
}


protected MR metricsRegistry;

@Before
Expand Down Expand Up @@ -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());
}

Expand Down