diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java index b99706c348..31c54c52ca 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -57,6 +57,21 @@ public class WavefrontProperties extends PushRegistryProperties { */ private String globalPrefix; + /** + * Whether to report histogram distributions aggregated into minute intervals. + */ + private boolean reportMinuteDistribution = true; + + /** + * Whether to report histogram distributions aggregated into hour intervals. + */ + private boolean reportHourDistribution; + + /** + * Whether to report histogram distributions aggregated into day intervals. + */ + private boolean reportDayDistribution; + private final Sender sender = new Sender(); public URI getUri() { @@ -95,6 +110,30 @@ public class WavefrontProperties extends PushRegistryProperties { return this.sender; } + public boolean isReportMinuteDistribution() { + return this.reportMinuteDistribution; + } + + public void setReportMinuteDistribution(boolean reportMinuteDistribution) { + this.reportMinuteDistribution = reportMinuteDistribution; + } + + public boolean isReportHourDistribution() { + return this.reportHourDistribution; + } + + public void setReportHourDistribution(boolean reportHourDistribution) { + this.reportHourDistribution = reportHourDistribution; + } + + public boolean isReportDayDistribution() { + return this.reportDayDistribution; + } + + public void setReportDayDistribution(boolean reportDayDistribution) { + this.reportDayDistribution = reportDayDistribution; + } + public static class Sender { /** diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java index 22b0716479..265e17e145 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 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. @@ -48,6 +48,10 @@ public class WavefrontPropertiesConfigAdapter extends PushRegistryPropertiesConf return get(this::getUriAsString, WavefrontConfig.DEFAULT_DIRECT::uri); } + private String getUriAsString(WavefrontProperties properties) { + return (properties.getUri() != null) ? properties.getUri().toString() : null; + } + @Override public String source() { return get(WavefrontProperties::getSource, WavefrontConfig.super::source); @@ -63,8 +67,19 @@ public class WavefrontPropertiesConfigAdapter extends PushRegistryPropertiesConf return get(WavefrontProperties::getGlobalPrefix, WavefrontConfig.super::globalPrefix); } - private String getUriAsString(WavefrontProperties properties) { - return (properties.getUri() != null) ? properties.getUri().toString() : null; + @Override + public boolean reportMinuteDistribution() { + return get(WavefrontProperties::isReportMinuteDistribution, WavefrontConfig.super::reportMinuteDistribution); + } + + @Override + public boolean reportHourDistribution() { + return get(WavefrontProperties::isReportHourDistribution, WavefrontConfig.super::reportHourDistribution); + } + + @Override + public boolean reportDayDistribution() { + return get(WavefrontProperties::isReportDayDistribution, WavefrontConfig.super::reportDayDistribution); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapterTests.java index 82a5b6d31d..f596956de1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2023 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. @@ -70,4 +70,25 @@ class WavefrontPropertiesConfigAdapterTests assertThat(createConfigAdapter(properties).globalPrefix()).isEqualTo("test"); } + @Test + void whenPropertiesReportMinuteDistributionIsSetAdapterReportMinuteDistributionReturnsIt() { + WavefrontProperties properties = createProperties(); + properties.setReportMinuteDistribution(false); + assertThat(createConfigAdapter(properties).reportMinuteDistribution()).isFalse(); + } + + @Test + void whenPropertiesReportHourDistributionIsSetAdapterReportHourDistributionReturnsIt() { + WavefrontProperties properties = createProperties(); + properties.setReportHourDistribution(true); + assertThat(createConfigAdapter(properties).reportHourDistribution()).isTrue(); + } + + @Test + void whenPropertiesReportDayDistributionIsSetAdapterReportDayDistributionReturnsIt() { + WavefrontProperties properties = createProperties(); + properties.setReportDayDistribution(true); + assertThat(createConfigAdapter(properties).reportDayDistribution()).isTrue(); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java index 4ec6050d46..72e1e76b2f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2023 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. @@ -37,6 +37,9 @@ class WavefrontPropertiesTests extends PushRegistryPropertiesTests { assertStepRegistryDefaultValues(properties, config); assertThat(properties.getUri().toString()).isEqualTo(config.uri()); assertThat(properties.getGlobalPrefix()).isEqualTo(config.globalPrefix()); + assertThat(properties.isReportMinuteDistribution()).isEqualTo(config.reportMinuteDistribution()); + assertThat(properties.isReportHourDistribution()).isEqualTo(config.reportHourDistribution()); + assertThat(properties.isReportDayDistribution()).isEqualTo(config.reportDayDistribution()); } }