Search in sources :

Example 1 with ServletFilterSpanDecorator

use of io.opentracing.contrib.web.servlet.filter.ServletFilterSpanDecorator in project java-spring-web by opentracing-contrib.

the class ServerTracingAutoConfiguration method tracingFilter.

@Bean
@ConditionalOnMissingBean(TracingFilter.class)
public FilterRegistrationBean tracingFilter(Tracer tracer, WebTracingProperties tracingConfiguration) {
    log.info(format("Creating %s bean with %s mapped to %s, skip pattern is \"%s\"", FilterRegistrationBean.class.getSimpleName(), TracingFilter.class.getSimpleName(), tracingConfiguration.getUrlPatterns().toString(), tracingConfiguration.getSkipPattern()));
    List<ServletFilterSpanDecorator> decorators = servletFilterSpanDecorator.getIfAvailable();
    if (CollectionUtils.isEmpty(decorators)) {
        decorators = Collections.singletonList(ServletFilterSpanDecorator.STANDARD_TAGS);
    }
    TracingFilter tracingFilter = new TracingFilter(tracer, decorators, tracingConfiguration.getSkipPattern());
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(tracingFilter);
    filterRegistrationBean.setUrlPatterns(tracingConfiguration.getUrlPatterns());
    filterRegistrationBean.setOrder(tracingConfiguration.getOrder());
    filterRegistrationBean.setAsyncSupported(true);
    return filterRegistrationBean;
}
Also used : TracingFilter(io.opentracing.contrib.web.servlet.filter.TracingFilter) ServletFilterSpanDecorator(io.opentracing.contrib.web.servlet.filter.ServletFilterSpanDecorator) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

ServletFilterSpanDecorator (io.opentracing.contrib.web.servlet.filter.ServletFilterSpanDecorator)1 TracingFilter (io.opentracing.contrib.web.servlet.filter.TracingFilter)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)1 Bean (org.springframework.context.annotation.Bean)1