File tree 4 files changed +41
-0
lines changed
spring-boot-project/spring-boot-actuator-autoconfigure/src
main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp
test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/otlp
4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import java .util .Map ;
20
20
21
+ import io .micrometer .registry .otlp .AggregationTemporality ;
22
+
21
23
import org .springframework .boot .actuate .autoconfigure .metrics .export .properties .StepRegistryProperties ;
22
24
import org .springframework .boot .context .properties .ConfigurationProperties ;
23
25
26
28
* export.
27
29
*
28
30
* @author Eddú Meléndez
31
+ * @author Jonatan Ivanov
29
32
* @since 3.0.0
30
33
*/
31
34
@ ConfigurationProperties (prefix = "management.otlp.metrics.export" )
@@ -36,6 +39,12 @@ public class OtlpProperties extends StepRegistryProperties {
36
39
*/
37
40
private String url = "http://localhost:4318/v1/metrics" ;
38
41
42
+ /**
43
+ * Aggregation temporality of sums. It defines the way additive values are expressed.
44
+ * This setting depends on the backend you use, some only support one temporality.
45
+ */
46
+ private AggregationTemporality aggregationTemporality = AggregationTemporality .CUMULATIVE ;
47
+
39
48
/**
40
49
* Monitored resource's attributes.
41
50
*/
@@ -54,6 +63,14 @@ public void setUrl(String url) {
54
63
this .url = url ;
55
64
}
56
65
66
+ public AggregationTemporality getAggregationTemporality () {
67
+ return this .aggregationTemporality ;
68
+ }
69
+
70
+ public void setAggregationTemporality (AggregationTemporality aggregationTemporality ) {
71
+ this .aggregationTemporality = aggregationTemporality ;
72
+ }
73
+
57
74
public Map <String , String > getResourceAttributes () {
58
75
return this .resourceAttributes ;
59
76
}
Original file line number Diff line number Diff line change 18
18
19
19
import java .util .Map ;
20
20
21
+ import io .micrometer .registry .otlp .AggregationTemporality ;
21
22
import io .micrometer .registry .otlp .OtlpConfig ;
22
23
23
24
import org .springframework .boot .actuate .autoconfigure .metrics .export .properties .StepRegistryPropertiesConfigAdapter ;
26
27
* Adapter to convert {@link OtlpProperties} to an {@link OtlpConfig}.
27
28
*
28
29
* @author Eddú Meléndez
30
+ * @author Jonatan Ivanov
29
31
*/
30
32
class OtlpPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter <OtlpProperties > implements OtlpConfig {
31
33
@@ -43,6 +45,11 @@ public String url() {
43
45
return get (OtlpProperties ::getUrl , OtlpConfig .super ::url );
44
46
}
45
47
48
+ @ Override
49
+ public AggregationTemporality aggregationTemporality () {
50
+ return get (OtlpProperties ::getAggregationTemporality , OtlpConfig .super ::aggregationTemporality );
51
+ }
52
+
46
53
@ Override
47
54
public Map <String , String > resourceAttributes () {
48
55
return get (OtlpProperties ::getResourceAttributes , OtlpConfig .super ::resourceAttributes );
Original file line number Diff line number Diff line change 18
18
19
19
import java .util .Map ;
20
20
21
+ import io .micrometer .registry .otlp .AggregationTemporality ;
21
22
import org .junit .jupiter .api .Test ;
22
23
23
24
import static org .assertj .core .api .Assertions .assertThat ;
@@ -36,6 +37,21 @@ void whenPropertiesUrlIsSetAdapterUrlReturnsIt() {
36
37
assertThat (new OtlpPropertiesConfigAdapter (properties ).url ()).isEqualTo ("http://another-url:4318/v1/metrics" );
37
38
}
38
39
40
+ @ Test
41
+ void whenPropertiesAggregationTemporalityIsNotSetAdapterAggregationTemporalityReturnsCumulative () {
42
+ OtlpProperties properties = new OtlpProperties ();
43
+ assertThat (new OtlpPropertiesConfigAdapter (properties ).aggregationTemporality ())
44
+ .isSameAs (AggregationTemporality .CUMULATIVE );
45
+ }
46
+
47
+ @ Test
48
+ void whenPropertiesAggregationTemporalityIsSetAdapterAggregationTemporalityReturnsIt () {
49
+ OtlpProperties properties = new OtlpProperties ();
50
+ properties .setAggregationTemporality (AggregationTemporality .DELTA );
51
+ assertThat (new OtlpPropertiesConfigAdapter (properties ).aggregationTemporality ())
52
+ .isSameAs (AggregationTemporality .DELTA );
53
+ }
54
+
39
55
@ Test
40
56
void whenPropertiesResourceAttributesIsSetAdapterResourceAttributesReturnsIt () {
41
57
OtlpProperties properties = new OtlpProperties ();
Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ void defaultValuesAreConsistent() {
36
36
OtlpConfig config = OtlpConfig .DEFAULT ;
37
37
assertStepRegistryDefaultValues (properties , config );
38
38
assertThat (properties .getUrl ()).isEqualTo (config .url ());
39
+ assertThat (properties .getAggregationTemporality ()).isSameAs (config .aggregationTemporality ());
39
40
}
40
41
41
42
}
You can’t perform that action at this time.
0 commit comments