Class OpentracingResponseFilter

  • All Implemented Interfaces:
    EventListener, javax.servlet.Filter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.ServletContextAware

    public class OpentracingResponseFilter
    extends AbstractGenericFilterBean
    implements org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>
    A filter that adds the trace id to the response header.

    The filter uses the configured tracer's ability to inject itself into HTTP header fields. So whatever is configured for propagating the tracer's context, is used here as well. This allows switching between, for instance Jaeger and Zipkin format.

    Since:
    3.0.0.M11
    Author:
    Rutger Lubbers
    • Field Summary

      • Fields inherited from class org.springframework.web.filter.GenericFilterBean

        logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doFilterInternal​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)
      Same contract as for doFilter.
      void onApplicationEvent​(org.springframework.boot.context.event.ApplicationReadyEvent event)  
      void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
      • Methods inherited from class org.springframework.web.filter.GenericFilterBean

        addRequiredProperty, afterPropertiesSet, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
    • Constructor Detail

      • OpentracingResponseFilter

        public OpentracingResponseFilter()
    • Method Detail

      • doFilterInternal

        protected void doFilterInternal​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        javax.servlet.FilterChain filterChain)
                                 throws javax.servlet.ServletException,
                                        IOException
        Same contract as for doFilter.
        Specified by:
        doFilterInternal in class AbstractGenericFilterBean
        Throws:
        javax.servlet.ServletException
        IOException
      • setApplicationContext

        public void setApplicationContext​(@NonNull
                                          org.springframework.context.ApplicationContext applicationContext)
                                   throws org.springframework.beans.BeansException
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Throws:
        org.springframework.beans.BeansException
      • onApplicationEvent

        public void onApplicationEvent​(@NonNull
                                       org.springframework.boot.context.event.ApplicationReadyEvent event)
        Specified by:
        onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.boot.context.event.ApplicationReadyEvent>