From ed7b333138b028ee99c27bcce24ac6368d855312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJakub?= Date: Thu, 23 Jun 2022 15:15:13 +0200 Subject: [PATCH 1/2] Add missing descriptions for HTTP Server and Data repositories metrics See gh-31516 --- .../data/MetricsRepositoryMethodInvocationListener.java | 5 +++-- .../metrics/web/reactive/server/MetricsWebFilter.java | 3 ++- .../actuate/metrics/web/servlet/WebMvcMetricsFilter.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java index add03dc69179..5ebeaf1104c3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java @@ -83,8 +83,9 @@ public void afterInvocation(RepositoryMethodInvocation invocation) { Set annotations = TimedAnnotations.get(invocation.getMethod(), invocation.getRepositoryInterface()); Iterable tags = this.tagsProvider.repositoryTags(invocation); long duration = invocation.getDuration(TimeUnit.NANOSECONDS); - AutoTimer.apply(this.autoTimer, this.metricName, annotations, (builder) -> builder.tags(tags) - .register(this.registrySupplier.get()).record(duration, TimeUnit.NANOSECONDS)); + AutoTimer.apply(this.autoTimer, this.metricName, annotations, + (builder) -> builder.description("Duration of repository invocations").tags(tags) + .register(this.registrySupplier.get()).record(duration, TimeUnit.NANOSECONDS)); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java index 357ca2f76005..0f41b50fd7cc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java @@ -109,7 +109,8 @@ private void record(ServerWebExchange exchange, Throwable cause, long start) { Iterable tags = this.tagsProvider.httpRequestTags(exchange, cause); long duration = System.nanoTime() - start; AutoTimer.apply(this.autoTimer, this.metricName, annotations, - (builder) -> builder.tags(tags).register(this.registry).record(duration, TimeUnit.NANOSECONDS)); + (builder) -> builder.description("Duration of HTTP server request handling").tags(tags) + .register(this.registry).record(duration, TimeUnit.NANOSECONDS)); } catch (Exception ex) { logger.warn("Failed to record timer metrics", ex); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java index 8838253d0dfc..2f2a0c849759 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java @@ -158,7 +158,8 @@ private Set getTimedAnnotations(Object handler) { private Timer getTimer(Builder builder, Object handler, HttpServletRequest request, HttpServletResponse response, Throwable exception) { - return builder.tags(this.tagsProvider.getTags(request, response, handler, exception)).register(this.registry); + return builder.description("Duration of HTTP server request handling") + .tags(this.tagsProvider.getTags(request, response, handler, exception)).register(this.registry); } /** From 628a7b0c5c1043328ec028283fd25ad101614f14 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 13 Jul 2022 14:08:22 +0200 Subject: [PATCH 2/2] Update copyright year of changed files See gh-31516 --- .../metrics/data/MetricsRepositoryMethodInvocationListener.java | 2 +- .../actuate/metrics/web/reactive/server/MetricsWebFilter.java | 2 +- .../boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java index 5ebeaf1104c3..3ec34bc71a48 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/data/MetricsRepositoryMethodInvocationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java index 0f41b50fd7cc..2609055f06b2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/MetricsWebFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java index 2f2a0c849759..ae050db9d857 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.