SpanCustomizingAsyncHandlerInterceptor extends HandlerInterceptorAdapter { @Override public void afterCompletion( HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { Object span = request.getAttribute(SpanCustomizer.class.getName()); if (span instanceof SpanCustomizer) { setErrorAttribute(request, ex); setHttpRouteAttribute(request); } } SpanCustomizingAsyncHandlerInterceptor(); @Override boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object o); @Override void afterCompletion(
    HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex);  }
@Test public void afterCompletion_addsHttpRouteAttribute() { when(request.getAttribute("brave.SpanCustomizer")).thenReturn(span); when(request.getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE)).thenReturn("/items/{itemId}"); interceptor.afterCompletion(request, response, controller, null); verify(request).getAttribute("brave.SpanCustomizer"); verify(request).getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE); verify(request).setAttribute("http.route", "/items/{itemId}"); verifyNoMoreInteractions(request, response, parser, span); }
@Test public void afterCompletion_addsHttpRouteAttribute_coercesNullToEmpty() { when(request.getAttribute("brave.SpanCustomizer")).thenReturn(span); interceptor.afterCompletion(request, response, controller, null); verify(request).getAttribute("brave.SpanCustomizer"); verify(request).getAttribute(BEST_MATCHING_PATTERN_ATTRIBUTE); verify(request).setAttribute("http.route", ""); verifyNoMoreInteractions(request, response, parser, span); }