spring-cloud-sleuth icon indicating copy to clipboard operation
spring-cloud-sleuth copied to clipboard

Make it possible to apply TraceWebServletConfiguration in Servlet applications that don't use Spring MVC

Open gjdev opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

It looks like Spring Sleuth only extracts trace-information from incoming HttpServletRequests requests when Spring MVC is on the classpath. This isn't the case in all Spring Boot web applications of type Servlet. For instance (our case) when using spring-boot-starter-jersey, Spring Web MVC isn't used. But in that case TraceWebServletConfiguration autoconfig won't be enabled, since it has a ConditionalOnClass HandlerInterceptorAdapter from spring mvc. There is also no easy way to still include configuration from TraceWebServletConfiguration, which basically means that the functionality has to be duplicated in such Spring Boot apps.

(We had to create a configuration that creates traceWebAspect, traceWebFilter, and traceTomcatWebServerFactoryCustomizer beans, and implement a LazyTracingFilter to make web tracing work).

Describe the solution you'd like

Either:

  • Refactor TraceWebServletConfiguration to move the parts that configure specifically for Spring Web Mvc to another auto configuration, or:
  • Provide another easy way to apply the tracer beans created by TraceWebServletConfiguration.

Describe alternatives you've considered

As a workaround our code basically duplicates the TraceWebServletConfiguration by creating traceWebAspect, traceWebFilter, and traceTomcatWebServerFactoryCustomizer beans, and copying the implementation of LazyTracingFilter.

Additional context

Nothing to add here

gjdev avatar Aug 19 '22 20:08 gjdev