Skip to content

Commit ffc822d

Browse files
committed
Revisit metrics and tracing test properties
This commit renames 'spring.test.metrics.auto-configure' and 'spring.test.tracing.auto-configure' for consistency with the non-test properties. It also adds a configuration metadata entry for 'spring.test.observability.auto-configure' that's superseded by these two properties. Closes gh-47776
1 parent 58d8b93 commit ffc822d

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

core/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
"description": "Whether auto-configuration of JSON testers is enabled.",
77
"defaultValue": "true"
88
},
9+
{
10+
"name": "spring.test.observability.auto-configure",
11+
"deprecation": {
12+
"reason": "Superseded by 'spring.test.metrics.export' and 'spring.test.tracing.export'.",
13+
"level": "error"
14+
}
15+
},
916
{
1017
"name": "spring.test.print-condition-evaluation-report",
1118
"type": "java.lang.Boolean",

module/spring-boot-micrometer-metrics-test/src/main/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
*/
4242
class MetricsContextCustomizerFactory implements ContextCustomizerFactory {
4343

44-
// TODO spring.test.metrics.export?
45-
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.metrics.auto-configure";
44+
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.metrics.export";
4645

4746
@Override
4847
public ContextCustomizer createContextCustomizer(Class<?> testClass,

module/spring-boot-micrometer-metrics-test/src/main/resources/META-INF/spring-configuration-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"properties": [
33
{
4-
"name": "spring.test.metrics.auto-configure",
4+
"name": "spring.test.metrics.export",
55
"type": "java.lang.Boolean",
6-
"description": "Whether metrics should be auto-configured in tests.",
6+
"description": "Whether metrics export should be auto-configured in tests.",
77
"defaultValue": false
88
}
99
]

module/spring-boot-micrometer-metrics-test/src/test/java/org/springframework/boot/micrometer/metrics/test/autoconfigure/MetricsContextCustomizerFactoryTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ void metricsExportCanBeEnabledViaProperty() {
9494
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
9595
ConfigurableApplicationContext context = new GenericApplicationContext();
9696
MockEnvironment environment = new MockEnvironment();
97-
environment.setProperty("spring.test.metrics.auto-configure", "true");
97+
environment.setProperty("spring.test.metrics.export", "true");
9898
context.setEnvironment(environment);
9999
applyCustomizerToContext(customizer, context);
100100
assertThatMetricsAreEnabled(context);
101101
}
102102

103103
@Test
104-
void metricsCanBeDisabledViaProperty() {
104+
void metricsExportCanBeDisabledViaProperty() {
105105
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
106106
ConfigurableApplicationContext context = new GenericApplicationContext();
107107
MockEnvironment environment = new MockEnvironment();
108-
environment.setProperty("spring.test.metrics.auto-configure", "false");
108+
environment.setProperty("spring.test.metrics.export", "false");
109109
context.setEnvironment(environment);
110110
applyCustomizerToContext(customizer, context);
111111
assertThatMetricsAreDisabled(context);
@@ -116,7 +116,7 @@ void annotationTakesPrecedenceOverDisabledProperty() {
116116
ContextCustomizer customizer = createContextCustomizer(MetricsExportEnabled.class);
117117
ConfigurableApplicationContext context = new GenericApplicationContext();
118118
MockEnvironment environment = new MockEnvironment();
119-
environment.setProperty("spring.test.metrics.auto-configure", "false");
119+
environment.setProperty("spring.test.metrics.export", "false");
120120
context.setEnvironment(environment);
121121
applyCustomizerToContext(customizer, context);
122122
assertThatMetricsAreEnabled(context);
@@ -127,7 +127,7 @@ void annotationTakesPrecedenceOverEnabledProperty() {
127127
ContextCustomizer customizer = createContextCustomizer(MetricsExportDisabled.class);
128128
ConfigurableApplicationContext context = new GenericApplicationContext();
129129
MockEnvironment environment = new MockEnvironment();
130-
environment.setProperty("spring.test.metrics.auto-configure", "true");
130+
environment.setProperty("spring.test.metrics.export", "true");
131131
context.setEnvironment(environment);
132132
applyCustomizerToContext(customizer, context);
133133
assertThatMetricsAreDisabled(context);

module/spring-boot-micrometer-tracing-test/src/main/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@
4141
*/
4242
class TracingContextCustomizerFactory implements ContextCustomizerFactory {
4343

44-
// TODO spring.test.tracing.export?
45-
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.tracing.auto-configure";
44+
static final String AUTO_CONFIGURE_PROPERTY = "spring.test.tracing.export";
4645

4746
@Override
4847
public ContextCustomizer createContextCustomizer(Class<?> testClass,

module/spring-boot-micrometer-tracing-test/src/main/resources/META-INF/spring-configuration-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"properties": [
33
{
4-
"name": "spring.test.tracing.auto-configure",
4+
"name": "spring.test.tracing.export",
55
"type": "java.lang.Boolean",
6-
"description": "Whether tracing should be auto-configured in tests.",
6+
"description": "Whether tracing export should be auto-configured in tests.",
77
"defaultValue": false
88
}
99
]

module/spring-boot-micrometer-tracing-test/src/test/java/org/springframework/boot/micrometer/tracing/test/autoconfigure/TracingContextCustomizerFactoryTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void tracingExportCanBeEnabledViaProperty() {
9393
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
9494
ConfigurableApplicationContext context = new GenericApplicationContext();
9595
MockEnvironment environment = new MockEnvironment();
96-
environment.setProperty("spring.test.tracing.auto-configure", "true");
96+
environment.setProperty("spring.test.tracing.export", "true");
9797
context.setEnvironment(environment);
9898
applyCustomizerToContext(customizer, context);
9999
assertThatTracingExportIsEnabled(context);
@@ -104,7 +104,7 @@ void tracingExportCanBeDisabledViaProperty() {
104104
ContextCustomizer customizer = createContextCustomizer(NoAnnotation.class);
105105
ConfigurableApplicationContext context = new GenericApplicationContext();
106106
MockEnvironment environment = new MockEnvironment();
107-
environment.setProperty("spring.test.tracing.auto-configure", "false");
107+
environment.setProperty("spring.test.tracing.export", "false");
108108
context.setEnvironment(environment);
109109
applyCustomizerToContext(customizer, context);
110110
assertThatTracingExportIsDisabled(context);
@@ -115,7 +115,7 @@ void annotationTakesPrecedenceOverDisabledProperty() {
115115
ContextCustomizer customizer = createContextCustomizer(TracingExportEnabled.class);
116116
ConfigurableApplicationContext context = new GenericApplicationContext();
117117
MockEnvironment environment = new MockEnvironment();
118-
environment.setProperty("spring.test.tracing.auto-configure", "false");
118+
environment.setProperty("spring.test.tracing.export", "false");
119119
context.setEnvironment(environment);
120120
applyCustomizerToContext(customizer, context);
121121
assertThatTracingExportIsEnabled(context);
@@ -126,7 +126,7 @@ void annotationTakesPrecedenceOverEnabledProperty() {
126126
ContextCustomizer customizer = createContextCustomizer(TracingExportDisabled.class);
127127
ConfigurableApplicationContext context = new GenericApplicationContext();
128128
MockEnvironment environment = new MockEnvironment();
129-
environment.setProperty("spring.test.tracing.auto-configure", "true");
129+
environment.setProperty("spring.test.tracing.export", "true");
130130
context.setEnvironment(environment);
131131
applyCustomizerToContext(customizer, context);
132132
assertThatTracingExportIsDisabled(context);

0 commit comments

Comments
 (0)