From 24e748d5cd8c3c8ef580d9cf7184db3be37384ab Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Fri, 25 Mar 2022 16:13:28 +0100 Subject: [PATCH] Remove unnecessary entries in additional config metadata Add the 'enabled' fields directly to the classes instead. Closes gh-30439 --- .../metrics/export/jmx/JmxProperties.java | 15 ++++++++++++++- .../prometheus/PrometheusProperties.java | 15 ++++++++++++++- .../export/simple/SimpleProperties.java | 15 ++++++++++++++- ...ditional-spring-configuration-metadata.json | 18 ------------------ 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxProperties.java index 2d927d34fe06..ea4adb908203 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -31,6 +31,11 @@ @ConfigurationProperties(prefix = "management.metrics.export.jmx") public class JmxProperties { + /** + * Whether exporting of metrics to this backend is enabled. + */ + private boolean enabled = true; + /** * Metrics JMX domain name. */ @@ -57,4 +62,12 @@ public void setStep(Duration step) { this.step = step; } + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java index 3d3013665070..41b7845f62e4 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 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. @@ -36,6 +36,11 @@ @ConfigurationProperties(prefix = "management.metrics.export.prometheus") public class PrometheusProperties { + /** + * Whether exporting of metrics to this backend is enabled. + */ + private boolean enabled = true; + /** * Whether to enable publishing descriptions as part of the scrape payload to * Prometheus. Turn this off to minimize the amount of data sent on each scrape. @@ -82,6 +87,14 @@ public void setStep(Duration step) { this.step = step; } + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + public Pushgateway getPushgateway() { return this.pushgateway; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java index 5433ea65107a..8d4a1e263d02 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -34,6 +34,11 @@ @ConfigurationProperties(prefix = "management.metrics.export.simple") public class SimpleProperties { + /** + * Whether exporting of metrics to this backend is enabled. + */ + private boolean enabled = true; + /** * Step size (i.e. reporting frequency) to use. */ @@ -44,6 +49,14 @@ public class SimpleProperties { */ private CountingMode mode = CountingMode.CUMULATIVE; + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + public Duration getStep() { return this.step; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 9c35406c44f0..f84df137a23d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -421,12 +421,6 @@ "level": "error" } }, - { - "name": "management.metrics.export.jmx.enabled", - "type": "java.lang.Boolean", - "description": "Whether exporting of metrics to JMX is enabled.", - "defaultValue": true - }, { "name": "management.metrics.export.kairos.num-threads", "type": "java.lang.Integer", @@ -444,12 +438,6 @@ "level": "error" } }, - { - "name": "management.metrics.export.prometheus.enabled", - "type": "java.lang.Boolean", - "description": "Whether exporting of metrics to Prometheus is enabled.", - "defaultValue": true - }, { "name": "management.metrics.export.prometheus.histogram-flavor", "defaultValue": "prometheus" @@ -467,12 +455,6 @@ "level": "error" } }, - { - "name": "management.metrics.export.simple.enabled", - "type": "java.lang.Boolean", - "description": "Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled.", - "defaultValue": true - }, { "name": "management.metrics.export.simple.mode", "defaultValue": "cumulative"