Skip to content

Commit 6e4bece

Browse files
committed
Make auto-configured OtelTracer back off when user defines a Tracer
Closes gh-33097
1 parent d91e16a commit 6e4bece

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Tracer otelTracer(OpenTelemetry openTelemetry) {
135135
}
136136

137137
@Bean
138-
@ConditionalOnMissingBean
138+
@ConditionalOnMissingBean(io.micrometer.tracing.Tracer.class)
139139
OtelTracer micrometerOtelTracer(Tracer tracer, EventPublisher eventPublisher,
140140
OtelCurrentTraceContext otelCurrentTraceContext) {
141141
return new OtelTracer(tracer, otelCurrentTraceContext, eventPublisher,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ void shouldNotSupplyBeansIfDependencyIsMissing(String packageName) {
106106
@Test
107107
void shouldBackOffOnCustomBeans() {
108108
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
109-
assertThat(context).hasBean("customOtelTracer");
110-
assertThat(context).hasSingleBean(OtelTracer.class);
109+
assertThat(context).hasBean("customMicrometerTracer");
110+
assertThat(context).hasSingleBean(io.micrometer.tracing.Tracer.class);
111111
assertThat(context).hasBean("customEventPublisher");
112112
assertThat(context).hasSingleBean(EventPublisher.class);
113113
assertThat(context).hasBean("customOtelCurrentTraceContext");
@@ -201,8 +201,8 @@ void shouldSupplyW3CPropagationWithoutBaggageWhenDisabled() {
201201
private static class CustomConfiguration {
202202

203203
@Bean
204-
OtelTracer customOtelTracer() {
205-
return mock(OtelTracer.class);
204+
io.micrometer.tracing.Tracer customMicrometerTracer() {
205+
return mock(io.micrometer.tracing.Tracer.class);
206206
}
207207

208208
@Bean

0 commit comments

Comments
 (0)