@Test public void testNullRequestPath() throws IOException, ServletException { doReturn(StringUtils.EMPTY).when(request).getRequestURI(); filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain()); verify(metricsController, times(0)).startRequest(); verify(metricsController, times(0)).startIntegrationExecution(anyString()); verify(metricsController, times(0)).finishIntegrationExecution(any(Timer.Context.class)); verify(metricsController, times(0)).finishRequest(any(Timer.Context.class), anyInt()); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Timer.Context requestContext = null; Timer.Context webhookContext = null; boolean logRequest = true; try { HttpServletRequest request = (HttpServletRequest) servletRequest; String pathInfo = request.getRequestURI().replace(request.getContextPath(), StringUtils.EMPTY); logRequest = shouldLogRequest(pathInfo); if (logRequest) { requestContext = metricsController.startRequest(); if (isWebHookResource(pathInfo)) { String path = pathInfo.replace(integrationUrlParam, StringUtils.EMPTY); String integration = path.substring(0, path.indexOf("/")); webhookContext = metricsController.startIntegrationExecution(integration); } } filterChain.doFilter(servletRequest, servletResponse); } finally { if (logRequest) { metricsController.finishIntegrationExecution(webhookContext); HttpServletResponse response = (HttpServletResponse) servletResponse; metricsController.finishRequest(requestContext, response.getStatus()); } } }
IntegrationMetricsFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Timer.Context requestContext = null; Timer.Context webhookContext = null; boolean logRequest = true; try { HttpServletRequest request = (HttpServletRequest) servletRequest; String pathInfo = request.getRequestURI().replace(request.getContextPath(), StringUtils.EMPTY); logRequest = shouldLogRequest(pathInfo); if (logRequest) { requestContext = metricsController.startRequest(); if (isWebHookResource(pathInfo)) { String path = pathInfo.replace(integrationUrlParam, StringUtils.EMPTY); String integration = path.substring(0, path.indexOf("/")); webhookContext = metricsController.startIntegrationExecution(integration); } } filterChain.doFilter(servletRequest, servletResponse); } finally { if (logRequest) { metricsController.finishIntegrationExecution(webhookContext); HttpServletResponse response = (HttpServletResponse) servletResponse; metricsController.finishRequest(requestContext, response.getStatus()); } } } }
IntegrationMetricsFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Timer.Context requestContext = null; Timer.Context webhookContext = null; boolean logRequest = true; try { HttpServletRequest request = (HttpServletRequest) servletRequest; String pathInfo = request.getRequestURI().replace(request.getContextPath(), StringUtils.EMPTY); logRequest = shouldLogRequest(pathInfo); if (logRequest) { requestContext = metricsController.startRequest(); if (isWebHookResource(pathInfo)) { String path = pathInfo.replace(integrationUrlParam, StringUtils.EMPTY); String integration = path.substring(0, path.indexOf("/")); webhookContext = metricsController.startIntegrationExecution(integration); } } filterChain.doFilter(servletRequest, servletResponse); } finally { if (logRequest) { metricsController.finishIntegrationExecution(webhookContext); HttpServletResponse response = (HttpServletResponse) servletResponse; metricsController.finishRequest(requestContext, response.getStatus()); } } }  }
IntegrationMetricsFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Timer.Context requestContext = null; Timer.Context webhookContext = null; boolean logRequest = true; try { HttpServletRequest request = (HttpServletRequest) servletRequest; String pathInfo = request.getRequestURI().replace(request.getContextPath(), StringUtils.EMPTY); logRequest = shouldLogRequest(pathInfo); if (logRequest) { requestContext = metricsController.startRequest(); if (isWebHookResource(pathInfo)) { String path = pathInfo.replace(integrationUrlParam, StringUtils.EMPTY); String integration = path.substring(0, path.indexOf("/")); webhookContext = metricsController.startIntegrationExecution(integration); } } filterChain.doFilter(servletRequest, servletResponse); } finally { if (logRequest) { metricsController.finishIntegrationExecution(webhookContext); HttpServletResponse response = (HttpServletResponse) servletResponse; metricsController.finishRequest(requestContext, response.getStatus()); } } }  @Override void init(FilterConfig config); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
      FilterChain filterChain); @Override void destroy(); }
IntegrationMetricsFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { Timer.Context requestContext = null; Timer.Context webhookContext = null; boolean logRequest = true; try { HttpServletRequest request = (HttpServletRequest) servletRequest; String pathInfo = request.getRequestURI().replace(request.getContextPath(), StringUtils.EMPTY); logRequest = shouldLogRequest(pathInfo); if (logRequest) { requestContext = metricsController.startRequest(); if (isWebHookResource(pathInfo)) { String path = pathInfo.replace(integrationUrlParam, StringUtils.EMPTY); String integration = path.substring(0, path.indexOf("/")); webhookContext = metricsController.startIntegrationExecution(integration); } } filterChain.doFilter(servletRequest, servletResponse); } finally { if (logRequest) { metricsController.finishIntegrationExecution(webhookContext); HttpServletResponse response = (HttpServletResponse) servletResponse; metricsController.finishRequest(requestContext, response.getStatus()); } } }  @Override void init(FilterConfig config); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
      FilterChain filterChain); @Override void destroy(); static final String IGNORE_URL_PARAM; static final String WEBHOOK_URL_PARAM; }