Skip to content

Commit 2766c4b

Browse files
committed
Merge branch '3.0.x' into 3.1.x
Closes gh-36559
2 parents 22fa904 + d290d05 commit 2766c4b

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -54,6 +54,12 @@ public class StackdriverProperties extends StepRegistryProperties {
5454
*/
5555
private boolean useSemanticMetricTypes = false;
5656

57+
/**
58+
* Prefix for metric type. Valid prefixes are described in the Google Cloud
59+
* documentation (https://cloud.google.com/monitoring/custom-metrics#identifier).
60+
*/
61+
private String metricTypePrefix = "custom.googleapis.com/";
62+
5763
public String getProjectId() {
5864
return this.projectId;
5965
}
@@ -86,4 +92,12 @@ public void setUseSemanticMetricTypes(boolean useSemanticMetricTypes) {
8692
this.useSemanticMetricTypes = useSemanticMetricTypes;
8793
}
8894

95+
public String getMetricTypePrefix() {
96+
return this.metricTypePrefix;
97+
}
98+
99+
public void setMetricTypePrefix(String metricTypePrefix) {
100+
this.metricTypePrefix = metricTypePrefix;
101+
}
102+
89103
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -60,4 +60,9 @@ public boolean useSemanticMetricTypes() {
6060
return get(StackdriverProperties::isUseSemanticMetricTypes, StackdriverConfig.super::useSemanticMetricTypes);
6161
}
6262

63+
@Override
64+
public String metricTypePrefix() {
65+
return get(StackdriverProperties::getMetricTypePrefix, StackdriverConfig.super::metricTypePrefix);
66+
}
67+
6368
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,12 @@ void whenPropertiesUseSemanticMetricTypesIsSetAdapterUseSemanticMetricTypesRetur
6262
assertThat(new StackdriverPropertiesConfigAdapter(properties).useSemanticMetricTypes()).isTrue();
6363
}
6464

65+
@Test
66+
void whenPropertiesMetricTypePrefixIsSetAdapterMetricTypePrefixReturnsIt() {
67+
StackdriverProperties properties = new StackdriverProperties();
68+
properties.setMetricTypePrefix("external.googleapis.com/prometheus");
69+
assertThat(new StackdriverPropertiesConfigAdapter(properties).metricTypePrefix())
70+
.isEqualTo("external.googleapis.com/prometheus");
71+
}
72+
6573
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2023 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.getResourceType()).isEqualTo(config.resourceType());
3939
assertThat(properties.isUseSemanticMetricTypes()).isEqualTo(config.useSemanticMetricTypes());
40+
assertThat(properties.getMetricTypePrefix()).isEqualTo(config.metricTypePrefix());
4041
}
4142

4243
}

0 commit comments

Comments
 (0)