Skip to content

Commit f293f6a

Browse files
committed
Expose AppOptics's floorTimes property
Closes gh-20850
1 parent 888a81b commit f293f6a

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/appoptics/AppOpticsProperties.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,6 +46,12 @@ public class AppOpticsProperties extends StepRegistryProperties {
4646
*/
4747
private String hostTag = "instance";
4848

49+
/**
50+
* Whether to ship a floored time, useful when sending measurements from multiple
51+
* hosts to align them on a given time boundary.
52+
*/
53+
private boolean floorTimes;
54+
4955
/**
5056
* Number of measurements per request to use for this backend. If more measurements
5157
* are found, then multiple requests will be made.
@@ -81,6 +87,14 @@ public void setHostTag(String hostTag) {
8187
this.hostTag = hostTag;
8288
}
8389

90+
public boolean isFloorTimes() {
91+
return this.floorTimes;
92+
}
93+
94+
public void setFloorTimes(boolean floorTimes) {
95+
this.floorTimes = floorTimes;
96+
}
97+
8498
@Override
8599
public Integer getBatchSize() {
86100
return this.batchSize;

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/appoptics/AppOpticsPropertiesConfigAdapter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -47,4 +47,9 @@ public String hostTag() {
4747
return get(AppOpticsProperties::getHostTag, AppOpticsConfig.super::hostTag);
4848
}
4949

50+
@Override
51+
public boolean floorTimes() {
52+
return get(AppOpticsProperties::isFloorTimes, AppOpticsConfig.super::floorTimes);
53+
}
54+
5055
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/appoptics/AppOpticsPropertiesConfigAdapterTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,4 +61,11 @@ void whenPropertiesHostTagIsSetAdapterHostTagReturnsIt() {
6161
assertThat(createConfigAdapter(properties).hostTag()).isEqualTo("node");
6262
}
6363

64+
@Test
65+
void whenPropertiesFloorTimesIsSetAdapterHostTagReturnsIt() {
66+
AppOpticsProperties properties = createProperties();
67+
properties.setFloorTimes(true);
68+
assertThat(createConfigAdapter(properties).floorTimes()).isTrue();
69+
}
70+
6471
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/appoptics/AppOpticsPropertiesTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,6 +37,7 @@ void defaultValuesAreConsistent() {
3737
assertStepRegistryDefaultValues(properties, config);
3838
assertThat(properties.getUri()).isEqualToIgnoringWhitespace(config.uri());
3939
assertThat(properties.getHostTag()).isEqualToIgnoringWhitespace(config.hostTag());
40+
assertThat(properties.isFloorTimes()).isEqualTo(config.floorTimes());
4041
}
4142

4243
}

0 commit comments

Comments
 (0)