Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Apr 22, 2024
1 parent 7f080f1 commit 8245b66
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 7 additions & 0 deletions instrumentation/spring/spring-boot-autoconfigure-3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Why do we need a separate module for Spring Boot 3 auto-configuration?

`RestClientInstrumentationAutoConfiguration` imports `RestClientCustomizer`,
which is part of Spring Boot 3 (rather than Spring framework).

If we were to include this in the `spring-boot-autoconfigure` module, we would have to
bump the Spring Boot version to 3, which would break compatibility with Spring Boot 2.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ public RestClientBeanPostProcessor(ObjectProvider<OpenTelemetry> openTelemetryPr

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
if (!(bean instanceof RestClient)) {
return bean;
if (bean instanceof RestClient restClient) {
return addRestClientInterceptorIfNotPresent(restClient, openTelemetryProvider.getObject());
}
return addRestClientInterceptorIfNotPresent(
((RestClient) bean), openTelemetryProvider.getObject());
return bean;
}

private static RestClient addRestClientInterceptorIfNotPresent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.instrumentation.spring.autoconfigure.internal.SdkEnabled;
import io.opentelemetry.instrumentation.spring.web.v3_1.SpringWebTelemetry;
import io.opentelemetry.testing.internal.armeria.client.RestClient;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
Expand All @@ -19,6 +18,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestClient;

/**
* Configures {@link RestClient} for tracing.
Expand All @@ -33,8 +33,6 @@
@Configuration
public class RestClientInstrumentationAutoConfiguration {

public RestClientInstrumentationAutoConfiguration() {}

@Bean
static RestClientBeanPostProcessor otelRestClientBeanPostProcessor(
ObjectProvider<OpenTelemetry> openTelemetryProvider) {
Expand Down

0 comments on commit 8245b66

Please sign in to comment.