diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java index f6fcfcce3595..1d476f0790ad 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasProperties.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. @@ -78,6 +78,21 @@ public class AtlasProperties { */ private boolean lwcEnabled; + /** + * Step size (reporting frequency) to use for streaming to Atlas LWC. This is the + * highest supported resolution for getting an on-demand stream of the data. It must + * be less than or equal to management.metrics.export.atlas.step and + * management.metrics.export.atlas.step should be an even multiple of this value. + */ + private Duration lwcStep = Duration.ofSeconds(5); + + /** + * Whether expressions with the same step size as Atlas publishing should be ignored + * for streaming. Used for cases where data being published to Atlas is also sent into + * streaming from the backend. + */ + private boolean lwcIgnorePublishStep = true; + /** * Frequency for refreshing config settings from the LWC service. */ @@ -170,6 +185,22 @@ public void setLwcEnabled(boolean lwcEnabled) { this.lwcEnabled = lwcEnabled; } + public Duration getLwcStep() { + return this.lwcStep; + } + + public void setLwcStep(Duration lwcStep) { + this.lwcStep = lwcStep; + } + + public boolean isLwcIgnorePublishStep() { + return this.lwcIgnorePublishStep; + } + + public void setLwcIgnorePublishStep(boolean lwcIgnorePublishStep) { + this.lwcIgnorePublishStep = lwcIgnorePublishStep; + } + public Duration getConfigRefreshFrequency() { return this.configRefreshFrequency; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java index a79323f1174a..32458682b987 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapter.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. @@ -84,6 +84,16 @@ public boolean lwcEnabled() { return get(AtlasProperties::isLwcEnabled, AtlasConfig.super::lwcEnabled); } + @Override + public Duration lwcStep() { + return get(AtlasProperties::getLwcStep, AtlasConfig.super::lwcStep); + } + + @Override + public boolean lwcIgnorePublishStep() { + return get(AtlasProperties::isLwcIgnorePublishStep, AtlasConfig.super::lwcIgnorePublishStep); + } + @Override public Duration configRefreshFrequency() { return get(AtlasProperties::getConfigRefreshFrequency, AtlasConfig.super::configRefreshFrequency); diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapterTests.java index b84575c0f760..6b72df27399a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesConfigAdapterTests.java @@ -116,4 +116,18 @@ void whenPropertiesEvalUriIsSetAdapterEvalUriReturnsIt() { .isEqualTo("https://atlas.example.com/evaluate"); } + @Test + void whenPropertiesLwcStepIsSetAdapterLwcStepReturnsIt() { + AtlasProperties properties = new AtlasProperties(); + properties.setLwcStep(Duration.ofSeconds(30)); + assertThat(new AtlasPropertiesConfigAdapter(properties).lwcStep()).isEqualTo(Duration.ofSeconds(30)); + } + + @Test + void whenPropertiesLwcIgnorePublishStepIsSetAdapterLwcIgnorePublishStepReturnsIt() { + AtlasProperties properties = new AtlasProperties(); + properties.setLwcIgnorePublishStep(false); + assertThat(new AtlasPropertiesConfigAdapter(properties).lwcIgnorePublishStep()).isFalse(); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesTests.java index 7d345ad9c162..06289a8958ef 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasPropertiesTests.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. @@ -41,6 +41,8 @@ void defaultValuesAreConsistent() { assertThat(properties.getUri()).isEqualTo(config.uri()); assertThat(properties.getMeterTimeToLive()).isEqualTo(config.meterTTL()); assertThat(properties.isLwcEnabled()).isEqualTo(config.lwcEnabled()); + assertThat(properties.getLwcStep()).isEqualTo(config.lwcStep()); + assertThat(properties.isLwcIgnorePublishStep()).isEqualTo(config.lwcIgnorePublishStep()); assertThat(properties.getConfigRefreshFrequency()).isEqualTo(config.configRefreshFrequency()); assertThat(properties.getConfigTimeToLive()).isEqualTo(config.configTTL()); assertThat(properties.getConfigUri()).isEqualTo(config.configUri());