From e02eba2a33baca391743cf2777d996d5546de64d Mon Sep 17 00:00:00 2001 From: Jon Schneider Date: Thu, 8 Feb 2018 13:23:14 -0600 Subject: [PATCH 1/2] Add publishUnchangedMeters StatsD support Add configuration property to support publishing unchanged pollable meters. See gh-11967 --- .../metrics/export/statsd/StatsdProperties.java | 15 ++++++++++++++- .../statsd/StatsdPropertiesConfigAdapter.java | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java index b0e1203c03..89b6d0294b 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java @@ -59,7 +59,8 @@ public class StatsdProperties { /** * How often gauges will be polled. When a gauge is polled, its value is recalculated - * and if the value has changed, it is sent to the StatsD server. + * and if the value has changed (or publishUnchangedMeters is true), + * it is sent to the StatsD server. */ private Duration pollingFrequency = Duration.ofSeconds(10); @@ -68,6 +69,11 @@ public class StatsdProperties { */ private Integer queueSize = Integer.MAX_VALUE; + /** + * Send unchanged meters to the StatsD server. + */ + private Boolean publishUnchangedMeters = true; + public Boolean getEnabled() { return this.enabled; } @@ -124,4 +130,11 @@ public class StatsdProperties { this.queueSize = queueSize; } + public Boolean getPublishUnchangedMeters() { + return this.publishUnchangedMeters; + } + + public void setPublishUnchangedMeters(Boolean publishUnchangedMeters) { + this.publishUnchangedMeters = publishUnchangedMeters; + } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java index cc90e3ac4b..89e0b2de2a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java @@ -78,4 +78,8 @@ public class StatsdPropertiesConfigAdapter return get(StatsdProperties::getQueueSize, StatsdConfig.super::queueSize); } + @Override + public boolean publishUnchangedMeters() { + return get(StatsdProperties::getPublishUnchangedMeters, StatsdConfig.super::publishUnchangedMeters); + } } From 601157f552eb61cd28f1cf9c5d9d18f2198b2520 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 9 Feb 2018 12:09:12 -0800 Subject: [PATCH 2/2] Polish "Add publishUnchangedMeters StatsD support" Closes gh-11967 --- .../metrics/export/statsd/StatsdProperties.java | 7 ++++--- .../export/statsd/StatsdPropertiesConfigAdapter.java | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java index 89b6d0294b..14bb18754e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdProperties.java @@ -59,8 +59,8 @@ public class StatsdProperties { /** * How often gauges will be polled. When a gauge is polled, its value is recalculated - * and if the value has changed (or publishUnchangedMeters is true), - * it is sent to the StatsD server. + * and if the value has changed (or publishUnchangedMeters is true), it is sent to the + * StatsD server. */ private Duration pollingFrequency = Duration.ofSeconds(10); @@ -72,7 +72,7 @@ public class StatsdProperties { /** * Send unchanged meters to the StatsD server. */ - private Boolean publishUnchangedMeters = true; + private Boolean publishUnchangedMeters; public Boolean getEnabled() { return this.enabled; @@ -137,4 +137,5 @@ public class StatsdProperties { public void setPublishUnchangedMeters(Boolean publishUnchangedMeters) { this.publishUnchangedMeters = publishUnchangedMeters; } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java index 89e0b2de2a..cbc24ca5ec 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdPropertiesConfigAdapter.java @@ -80,6 +80,8 @@ public class StatsdPropertiesConfigAdapter @Override public boolean publishUnchangedMeters() { - return get(StatsdProperties::getPublishUnchangedMeters, StatsdConfig.super::publishUnchangedMeters); + return get(StatsdProperties::getPublishUnchangedMeters, + StatsdConfig.super::publishUnchangedMeters); } + }