|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2024 the original author or authors. |
| 2 | + * Copyright 2012-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
66 | 66 | class ObservationAutoConfigurationTests {
|
67 | 67 |
|
68 | 68 | private final ApplicationContextRunner contextRunner = new ApplicationContextRunner().with(MetricsRun.simple())
|
| 69 | + .withPropertyValues("management.observations.annotations.enabled=true") |
69 | 70 | .withClassLoader(new FilteredClassLoader("io.micrometer.tracing"))
|
70 | 71 | .withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class));
|
71 | 72 |
|
72 | 73 | private final ApplicationContextRunner tracingContextRunner = new ApplicationContextRunner()
|
73 | 74 | .with(MetricsRun.simple())
|
| 75 | + .withPropertyValues("management.observations.annotations.enabled=true") |
74 | 76 | .withUserConfiguration(TracerConfiguration.class)
|
75 | 77 | .withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class));
|
76 | 78 |
|
@@ -141,6 +143,7 @@ void supplyMeterHandlerAndGroupingWhenMicrometerCoreAndTracingAreOnClassPath() {
|
141 | 143 | @Test
|
142 | 144 | void supplyMeterHandlerAndGroupingWhenMicrometerCoreAndTracingAreOnClassPathButThereIsNoTracer() {
|
143 | 145 | new ApplicationContextRunner().with(MetricsRun.simple())
|
| 146 | + .withPropertyValues("management.observations.annotations.enabled=true") |
144 | 147 | .withConfiguration(AutoConfigurations.of(ObservationAutoConfiguration.class))
|
145 | 148 | .run((context) -> {
|
146 | 149 | ObservationRegistry observationRegistry = context.getBean(ObservationRegistry.class);
|
@@ -181,6 +184,21 @@ void allowsObservedAspectToBeDisabled() {
|
181 | 184 | .run((context) -> assertThat(context).doesNotHaveBean(ObservedAspect.class));
|
182 | 185 | }
|
183 | 186 |
|
| 187 | + @Test |
| 188 | + @Deprecated(since = "3.3.12", forRemoval = true) |
| 189 | + void allowsObservedAspectToBeEnabledWithLegacyProperty() { |
| 190 | + this.contextRunner |
| 191 | + .withPropertyValues("management.observations.annotations.enabled=false", |
| 192 | + "micrometer.observations.annotations.enabled=true") |
| 193 | + .run((context) -> assertThat(context).hasSingleBean(ObservedAspect.class)); |
| 194 | + } |
| 195 | + |
| 196 | + @Test |
| 197 | + void allowsObservedAspectToBeDisabledWithProperty() { |
| 198 | + this.contextRunner.withPropertyValues("management.observations.annotations.enabled=false") |
| 199 | + .run((context) -> assertThat(context).doesNotHaveBean(ObservedAspect.class)); |
| 200 | + } |
| 201 | + |
184 | 202 | @Test
|
185 | 203 | void allowsObservedAspectToBeCustomized() {
|
186 | 204 | this.contextRunner.withUserConfiguration(CustomObservedAspectConfiguration.class)
|
|
0 commit comments