Class OcHttpServletFilter

  • All Implemented Interfaces:
    javax.servlet.Filter

    @ExperimentalApi
    public class OcHttpServletFilter
    extends java.lang.Object
    implements javax.servlet.Filter
    This filter class implements Filter interface called by web container. The filter is used as an interceptor to enable tracing of http requests.
    Since:
    0.19
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static java.lang.String EXCEPTION_MESSAGE  
      (package private) static TextFormat.Getter<javax.servlet.http.HttpServletRequest> getter  
      (package private) HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> handler  
      static java.lang.String OC_EXTRACTOR
      Set optional OC_EXTRACTOR attribute in ServletContext with HttpExtractor customExtractor.
      static java.lang.String OC_PUBLIC_ENDPOINT
      Set optional OC_PUBLIC_ENDPOINT attribute in ServletContext with Boolean publicEndpoint.
      static java.lang.String OC_TRACE_PROPAGATOR
      Set optional OC_TRACE_PROPAGATOR attribute in ServletContext with TextFormat propagator.
    • Constructor Summary

      Constructors 
      Constructor Description
      OcHttpServletFilter()
      Creates a new OcHttpServletFilter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> buildHttpServerHandler()  
      (package private) static HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> buildHttpServerHandlerWithOptions​(HttpExtractor<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse> extractor, TextFormat propagator, java.lang.Boolean publicEndpoint)  
      void destroy()  
      void doFilter​(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)  
      void init​(javax.servlet.FilterConfig filterConfig)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • OC_TRACE_PROPAGATOR

        public static final java.lang.String OC_TRACE_PROPAGATOR
        Set optional OC_TRACE_PROPAGATOR attribute in ServletContext with TextFormat propagator. By default TraceContextFormat is used to propagate trace context.
        Since:
        0.20
        See Also:
        Constant Field Values
      • OC_EXTRACTOR

        public static final java.lang.String OC_EXTRACTOR
        Set optional OC_EXTRACTOR attribute in ServletContext with HttpExtractor customExtractor. Default extractor is used if custom extractor is not provided.
        Since:
        0.20
        See Also:
        Constant Field Values
      • OC_PUBLIC_ENDPOINT

        public static final java.lang.String OC_PUBLIC_ENDPOINT
        Set optional OC_PUBLIC_ENDPOINT attribute in ServletContext with Boolean publicEndpoint. set to true for publicly accessible HTTP(S) server. If true then incoming * tracecontext will be added as a link instead of as a parent. By default it is set to true.
        Since:
        0.20
        See Also:
        Constant Field Values
      • getter

        static final TextFormat.Getter<javax.servlet.http.HttpServletRequest> getter
      • handler

        HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> handler
    • Constructor Detail

      • OcHttpServletFilter

        public OcHttpServletFilter()
        Creates a new OcHttpServletFilter.
    • Method Detail

      • buildHttpServerHandler

        static HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> buildHttpServerHandler()
      • buildHttpServerHandlerWithOptions

        static HttpServerHandler<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse,​javax.servlet.http.HttpServletRequest> buildHttpServerHandlerWithOptions​(HttpExtractor<javax.servlet.http.HttpServletRequest,​javax.servlet.http.HttpServletResponse> extractor,
                                                                                                                                                                                                   TextFormat propagator,
                                                                                                                                                                                                   java.lang.Boolean publicEndpoint)
      • init

        public void init​(javax.servlet.FilterConfig filterConfig)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        java.io.IOException
        javax.servlet.ServletException
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter