Skip to content

Commit 3fc0764

Browse files
committed
Make auto-configured BatchSpanProcessor back off when the user defines their own
Closes gh-44601
1 parent 00b2fe7 commit 3fc0764

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryTracingAutoConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 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.
@@ -115,6 +115,7 @@ SpanProcessors spanProcessors(ObjectProvider<SpanProcessor> spanProcessors) {
115115
}
116116

117117
@Bean
118+
@ConditionalOnMissingBean
118119
BatchSpanProcessor otelSpanProcessor(SpanExporters spanExporters,
119120
ObjectProvider<SpanExportingPredicate> spanExportingPredicates, ObjectProvider<SpanReporter> spanReporters,
120121
ObjectProvider<SpanFilter> spanFilters, ObjectProvider<MeterProvider> meterProvider) {

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/OpenTelemetryTracingAutoConfigurationTests.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 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.
@@ -51,6 +51,7 @@
5151
import io.opentelemetry.sdk.trace.SpanLimits;
5252
import io.opentelemetry.sdk.trace.SpanProcessor;
5353
import io.opentelemetry.sdk.trace.data.SpanData;
54+
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
5455
import io.opentelemetry.sdk.trace.export.SpanExporter;
5556
import io.opentelemetry.sdk.trace.samplers.Sampler;
5657
import org.assertj.core.api.InstanceOfAssertFactories;
@@ -172,6 +173,8 @@ void shouldBackOffOnCustomBeans() {
172173
assertThat(context).hasSingleBean(SpanProcessors.class);
173174
assertThat(context).hasBean("customSpanExporters");
174175
assertThat(context).hasSingleBean(SpanExporters.class);
176+
assertThat(context).hasBean("customBatchSpanProcessor");
177+
assertThat(context).hasSingleBean(BatchSpanProcessor.class);
175178
});
176179
}
177180

@@ -401,6 +404,11 @@ SpanExporter spanExporter2() {
401404
@Configuration(proxyBeanMethods = false)
402405
private static final class CustomConfiguration {
403406

407+
@Bean
408+
BatchSpanProcessor customBatchSpanProcessor() {
409+
return mock(BatchSpanProcessor.class);
410+
}
411+
404412
@Bean
405413
SpanProcessors customSpanProcessors() {
406414
return SpanProcessors.of(mock(SpanProcessor.class));

0 commit comments

Comments
 (0)