From e9a272d6bca6cb12794729b4364da8c992da2370 Mon Sep 17 00:00:00 2001 From: Dominik Johs Date: Tue, 31 Jan 2023 09:34:57 +0100 Subject: [PATCH 1/2] upgrade to spring-boot 3 * add Autoconfiguration.imports * remove spring.factories * replace @Configuration with @AutoConfiguration * update dependencies and documentation * migrate testclass from javax to jakarta --- README.md | 6 +++--- pom.xml | 10 ++-------- .../metrics/MicrometerMetricsAutoConfiguration.java | 5 ++--- src/main/resources/META-INF/spring.factories | 1 - ...mework.boot.autoconfigure.AutoConfiguration.imports | 1 + .../metrics/testfixtures/TrivialDomain.java | 9 +++++---- src/test/resources/application.properties | 3 --- src/test/resources/application.yml | 6 ++++++ 8 files changed, 19 insertions(+), 22 deletions(-) delete mode 100644 src/main/resources/META-INF/spring.factories create mode 100644 src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports delete mode 100644 src/test/resources/application.properties create mode 100644 src/test/resources/application.yml diff --git a/README.md b/README.md index dcdcf12..60818b6 100644 --- a/README.md +++ b/README.md @@ -16,18 +16,18 @@ you will get the following measurements for every ```public``` method of the ``` ## Runtime Dependencies - Java >= 17 - - Spring Boot >= 2.7.6 + - Spring Boot >= 3.0.2 The library was compiled against: - - Spring Boot Acutator 2.7.6 + - Spring Boot Acutator 3.0.2 ## Installation ``` de.dm.infrastructure micrometer-metrics-wrapper - 1.4.1 + 2.0.0 ``` diff --git a/pom.xml b/pom.xml index d570d45..b63f48b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ de.dm.infrastructure micrometer-metrics-wrapper - 1.4.1-SNAPSHOT + 2.0.0-SNAPSHOT micrometer-metrics-wrapper Micrometer wrapper to allow generic class level metric values @@ -32,18 +32,12 @@ Dominik Johs dominik.johs@dm.de - - dmTECH GmbH - https://www.dmtech.de - Samuel Abt - samuel.abt@dm.de - org.springframework.boot spring-boot-starter-parent - 2.7.6 + 3.0.2 diff --git a/src/main/java/de/dm/infrastructure/metrics/MicrometerMetricsAutoConfiguration.java b/src/main/java/de/dm/infrastructure/metrics/MicrometerMetricsAutoConfiguration.java index 8830727..b3d70b1 100644 --- a/src/main/java/de/dm/infrastructure/metrics/MicrometerMetricsAutoConfiguration.java +++ b/src/main/java/de/dm/infrastructure/metrics/MicrometerMetricsAutoConfiguration.java @@ -3,12 +3,11 @@ import de.dm.infrastructure.metrics.aop.MetricAnnotationAdvisor; import de.dm.infrastructure.metrics.binder.GenericClassMethodMetrics; import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -@Configuration +@AutoConfiguration @AutoConfigureAfter(CompositeMeterRegistryAutoConfiguration.class) public class MicrometerMetricsAutoConfiguration { diff --git a/src/main/resources/META-INF/spring.factories b/src/main/resources/META-INF/spring.factories deleted file mode 100644 index ccff887..0000000 --- a/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=de.dm.infrastructure.metrics.MicrometerMetricsAutoConfiguration diff --git a/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..760dc26 --- /dev/null +++ b/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +de.dm.infrastructure.metrics.MicrometerMetricsAutoConfiguration diff --git a/src/test/java/de/dm/infrastructure/metrics/testfixtures/TrivialDomain.java b/src/test/java/de/dm/infrastructure/metrics/testfixtures/TrivialDomain.java index e77e39f..414529d 100644 --- a/src/test/java/de/dm/infrastructure/metrics/testfixtures/TrivialDomain.java +++ b/src/test/java/de/dm/infrastructure/metrics/testfixtures/TrivialDomain.java @@ -1,9 +1,10 @@ package de.dm.infrastructure.metrics.testfixtures; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; @Entity public class TrivialDomain { diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties deleted file mode 100644 index 0ba2f37..0000000 --- a/src/test/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -management.metrics.web.server.request.autotime.enabled=true -management.metrics.export.statsd.flavor=telegraf -management.metrics.export.statsd.enabled=true diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 0000000..8125e0c --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,6 @@ +management: + statsd: + metrics: + export: + enabled: true + flavor: telegraf From 49521c447e67c1a2eea3b23d73683c889558b96b Mon Sep 17 00:00:00 2001 From: Dominik Johs Date: Tue, 31 Jan 2023 09:44:04 +0100 Subject: [PATCH 2/2] update documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60818b6..33a9175 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ The library contains a default [micrometer-registry-statsd](https://github.com/m You can change this by setting the flavor property: ``` -management.metrics.export.statsd.flavor +management.statsd.metrics.export.flavor ``` The library also contains a set of default metrics which are provided from the [spring-boot-actuator](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-actuator)