How to manually configure OpenTracing Spring Web Instrumentation using xml

485 Views Asked by At

I've inherited a legacy Spring3 application, and I'm trying to add Lightstep instrumentation to it. I'm having trouble converting the instructions for manually configuration found here. https://github.com/opentracing-contrib/java-spring-web

In short, I need to convert the code block below to the xml equivalent.

@Configuration
@Import({TracingHandlerInterceptor.class})
public class MVCConfiguration extends WebMvcConfigurerAdapter {

    @Autowired
    private Tracer tracer;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TracingHandlerInterceptor(tracer));
    }

    @Bean
    public FilterRegistrationBean tracingFilter() {
        TracingFilter tracingFilter = new TracingFilter(tracer);

        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(tracingFilter);
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(Integer.MIN_VALUE);
        filterRegistrationBean.setAsyncSupported(true);

        return filterRegistrationBean;
    }
}

I've successfully created my Lightstep Tracer bean using the following dependencies.

compile group: 'com.lightstep.tracer', name: 'lightstep-tracer-jre', version: '0.14.8'

compile group: 'com.lightstep.tracer', name: 'tracer-okhttp', version: '0.15.10'

//https://mvnrepository.com/artifact/io.opentracing.contrib/opentracing-spring-web-starter
compile group: 'io.opentracing.contrib', name: 'opentracing-spring-web-starter', version: '0.3.3'
0

There are 0 best solutions below