Skip to content

Commit 2550efd

Browse files
Rename ConditionalOnEnabledTracing to ConditionalOnEnabledTracingExport
Signed-off-by: Maziyar Bahramian <maziyar.bahramian@gmail.com>
1 parent 5e8d1d4 commit 2550efd

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/testing/spring-boot-applications.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Regardless of your classpath, tracing components which are reporting data are no
233233

234234
If you need those components as part of an integration test, annotate the test with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation].
235235

236-
If you have created your own reporting components (e.g. a custom javadoc:io.opentelemetry.sdk.trace.export.SpanExporter[] or `brave.handler.SpanHandler`) and you don't want them to be active in tests, you can use the javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracing[format=annotation] annotation to disable them.
236+
If you have created your own reporting components (e.g. a custom javadoc:io.opentelemetry.sdk.trace.export.SpanExporter[] or `brave.handler.SpanHandler`) and you don't want them to be active in tests, you can use the javadoc:org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport[format=annotation] annotation to disable them.
237237

238238
If you annotate xref:testing/spring-boot-applications.adoc#testing.spring-boot-applications.autoconfigured-tests[a sliced test] with javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation], it auto-configures a no-op javadoc:io.micrometer.tracing.Tracer[].
239239
Data exporting in sliced tests is not supported with the javadoc:org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability[format=annotation] annotation.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static class PropagationWithoutBaggage {
5858

5959
@Bean
6060
@ConditionalOnMissingBean(Factory.class)
61-
@ConditionalOnEnabledTracing
61+
@ConditionalOnEnabledTracingExport
6262
CompositePropagationFactory propagationFactory(TracingProperties properties) {
6363
return CompositePropagationFactory.create(properties.getPropagation());
6464
}
@@ -127,7 +127,7 @@ BaggagePropagationCustomizer remoteFieldsBaggagePropagationCustomizer() {
127127

128128
@Bean
129129
@ConditionalOnMissingBean
130-
@ConditionalOnEnabledTracing
130+
@ConditionalOnEnabledTracingExport
131131
Factory propagationFactory(BaggagePropagation.FactoryBuilder factoryBuilder) {
132132
return factoryBuilder.build();
133133
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@Target({ ElementType.TYPE, ElementType.METHOD })
4040
@Documented
4141
@Conditional(OnEnabledTracingCondition.class)
42-
public @interface ConditionalOnEnabledTracing {
42+
public @interface ConditionalOnEnabledTracingExport {
4343

4444
/**
4545
* Name of the tracing exporter.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* {@link SpringBootCondition} to check whether tracing is enabled.
3232
*
3333
* @author Moritz Halbritter
34-
* @see ConditionalOnEnabledTracing
34+
* @see ConditionalOnEnabledTracingExport
3535
*/
3636
class OnEnabledTracingCondition extends SpringBootCondition {
3737

@@ -47,23 +47,23 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM
4747
.getProperty(EXPORTER_PROPERTY.formatted(tracingExporter), Boolean.class);
4848
if (exporterTracingEnabled != null) {
4949
return new ConditionOutcome(exporterTracingEnabled,
50-
ConditionMessage.forCondition(ConditionalOnEnabledTracing.class)
50+
ConditionMessage.forCondition(ConditionalOnEnabledTracingExport.class)
5151
.because(EXPORTER_PROPERTY.formatted(tracingExporter) + " is " + exporterTracingEnabled));
5252
}
5353
}
5454
Boolean globalTracingEnabled = context.getEnvironment().getProperty(GLOBAL_PROPERTY, Boolean.class);
5555
if (globalTracingEnabled != null) {
5656
return new ConditionOutcome(globalTracingEnabled,
57-
ConditionMessage.forCondition(ConditionalOnEnabledTracing.class)
57+
ConditionMessage.forCondition(ConditionalOnEnabledTracingExport.class)
5858
.because(GLOBAL_PROPERTY + " is " + globalTracingEnabled));
5959
}
60-
return ConditionOutcome.match(ConditionMessage.forCondition(ConditionalOnEnabledTracing.class)
60+
return ConditionOutcome.match(ConditionMessage.forCondition(ConditionalOnEnabledTracingExport.class)
6161
.because("tracing is enabled by default"));
6262
}
6363

6464
private static @Nullable String getExporterName(AnnotatedTypeMetadata metadata) {
6565
Map<String, @Nullable Object> attributes = metadata
66-
.getAnnotationAttributes(ConditionalOnEnabledTracing.class.getName());
66+
.getAnnotationAttributes(ConditionalOnEnabledTracingExport.class.getName());
6767
if (attributes == null) {
6868
return null;
6969
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class OpenTelemetryPropagationConfigurations {
4747
static class PropagationWithoutBaggage {
4848

4949
@Bean
50-
@ConditionalOnEnabledTracing
50+
@ConditionalOnEnabledTracingExport
5151
TextMapPropagator textMapPropagator(TracingProperties properties) {
5252
return CompositeTextMapPropagator.create(properties.getPropagation(), null);
5353
}
@@ -69,7 +69,7 @@ static class PropagationWithBaggage {
6969
}
7070

7171
@Bean
72-
@ConditionalOnEnabledTracing
72+
@ConditionalOnEnabledTracingExport
7373
TextMapPropagator textMapPropagatorWithBaggage(OtelCurrentTraceContext otelCurrentTraceContext) {
7474
List<String> remoteFields = this.tracingProperties.getBaggage().getRemoteFields();
7575
List<String> tagFields = this.tracingProperties.getBaggage().getTagFields();

module/spring-boot-micrometer-tracing/src/main/java/org/springframework/boot/micrometer/tracing/autoconfigure/otlp/OtlpTracingConfigurations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2929
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3030
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
31-
import org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracing;
31+
import org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport;
3232
import org.springframework.context.annotation.Bean;
3333
import org.springframework.context.annotation.Configuration;
3434
import org.springframework.util.Assert;
@@ -79,7 +79,7 @@ public String getUrl(Transport transport) {
7979
@Configuration(proxyBeanMethods = false)
8080
@ConditionalOnMissingBean({ OtlpGrpcSpanExporter.class, OtlpHttpSpanExporter.class })
8181
@ConditionalOnBean(OtlpTracingConnectionDetails.class)
82-
@ConditionalOnEnabledTracing("otlp")
82+
@ConditionalOnEnabledTracingExport("otlp")
8383
static class Exporters {
8484

8585
@Bean

module/spring-boot-micrometer-tracing/src/main/java/org/springframework/boot/micrometer/tracing/autoconfigure/zipkin/ZipkinTracingAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3535
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3636
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
37-
import org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracing;
37+
import org.springframework.boot.micrometer.tracing.autoconfigure.ConditionalOnEnabledTracingExport;
3838
import org.springframework.boot.micrometer.tracing.autoconfigure.zipkin.ZipkinTracingAutoConfiguration.BraveConfiguration;
3939
import org.springframework.boot.micrometer.tracing.autoconfigure.zipkin.ZipkinTracingAutoConfiguration.OpenTelemetryConfiguration;
4040
import org.springframework.context.annotation.Bean;
@@ -71,7 +71,7 @@ BytesEncoder<MutableSpan> mutableSpanBytesEncoder(Encoding encoding,
7171
@Bean
7272
@ConditionalOnMissingBean
7373
@ConditionalOnBean(BytesMessageSender.class)
74-
@ConditionalOnEnabledTracing("zipkin")
74+
@ConditionalOnEnabledTracingExport("zipkin")
7575
AsyncZipkinSpanHandler asyncZipkinSpanHandler(BytesMessageSender sender,
7676
BytesEncoder<MutableSpan> mutableSpanBytesEncoder) {
7777
return AsyncZipkinSpanHandler.newBuilder(sender).build(mutableSpanBytesEncoder);
@@ -93,7 +93,7 @@ BytesEncoder<Span> spanBytesEncoder(Encoding encoding) {
9393
@Bean
9494
@ConditionalOnMissingBean
9595
@ConditionalOnBean(BytesMessageSender.class)
96-
@ConditionalOnEnabledTracing("zipkin")
96+
@ConditionalOnEnabledTracingExport("zipkin")
9797
ZipkinSpanExporter zipkinSpanExporter(BytesMessageSender sender, BytesEncoder<Span> spanBytesEncoder) {
9898
return ZipkinSpanExporter.builder().setSender(sender).setEncoder(spanBytesEncoder).build();
9999
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void shouldMatchIfNoPropertyIsSet() {
4242
OnEnabledTracingCondition condition = new OnEnabledTracingCondition();
4343
ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(), mockMetadata(""));
4444
assertThat(outcome.isMatch()).isTrue();
45-
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing tracing is enabled by default");
45+
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracingExport tracing is enabled by default");
4646
}
4747

4848
@Test
@@ -51,7 +51,7 @@ void shouldNotMatchIfGlobalPropertyIsFalse() {
5151
ConditionOutcome outcome = condition
5252
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "false")), mockMetadata(""));
5353
assertThat(outcome.isMatch()).isFalse();
54-
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is false");
54+
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracingExport management.tracing.enabled is false");
5555
}
5656

5757
@Test
@@ -60,7 +60,7 @@ void shouldMatchIfGlobalPropertyIsTrue() {
6060
ConditionOutcome outcome = condition
6161
.getMatchOutcome(mockConditionContext(Map.of("management.tracing.enabled", "true")), mockMetadata(""));
6262
assertThat(outcome.isMatch()).isTrue();
63-
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracing management.tracing.enabled is true");
63+
assertThat(outcome.getMessage()).isEqualTo("@ConditionalOnEnabledTracingExport management.tracing.enabled is true");
6464
}
6565

6666
@Test
@@ -71,7 +71,7 @@ void shouldNotMatchIfExporterPropertyIsFalse() {
7171
mockMetadata("zipkin"));
7272
assertThat(outcome.isMatch()).isFalse();
7373
assertThat(outcome.getMessage())
74-
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
74+
.isEqualTo("@ConditionalOnEnabledTracingExport management.zipkin.tracing.export.enabled is false");
7575
}
7676

7777
@Test
@@ -82,7 +82,7 @@ void shouldMatchIfExporterPropertyIsTrue() {
8282
mockMetadata("zipkin"));
8383
assertThat(outcome.isMatch()).isTrue();
8484
assertThat(outcome.getMessage())
85-
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
85+
.isEqualTo("@ConditionalOnEnabledTracingExport management.zipkin.tracing.export.enabled is true");
8686
}
8787

8888
@Test
@@ -93,7 +93,7 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() {
9393
mockMetadata("zipkin"));
9494
assertThat(outcome.isMatch()).isTrue();
9595
assertThat(outcome.getMessage())
96-
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is true");
96+
.isEqualTo("@ConditionalOnEnabledTracingExport management.zipkin.tracing.export.enabled is true");
9797
}
9898

9999
@Test
@@ -104,7 +104,7 @@ void exporterPropertyShouldOverrideGlobalPropertyIfFalse() {
104104
mockMetadata("zipkin"));
105105
assertThat(outcome.isMatch()).isFalse();
106106
assertThat(outcome.getMessage())
107-
.isEqualTo("@ConditionalOnEnabledTracing management.zipkin.tracing.export.enabled is false");
107+
.isEqualTo("@ConditionalOnEnabledTracingExport management.zipkin.tracing.export.enabled is false");
108108
}
109109

110110
private ConditionContext mockConditionContext() {
@@ -121,7 +121,7 @@ private ConditionContext mockConditionContext(Map<String, String> properties) {
121121

122122
private AnnotatedTypeMetadata mockMetadata(String exporter) {
123123
AnnotatedTypeMetadata metadata = mock(AnnotatedTypeMetadata.class);
124-
given(metadata.getAnnotationAttributes(ConditionalOnEnabledTracing.class.getName()))
124+
given(metadata.getAnnotationAttributes(ConditionalOnEnabledTracingExport.class.getName()))
125125
.willReturn(Map.of("value", exporter));
126126
return metadata;
127127
}

0 commit comments

Comments
 (0)