HandlerParser { protected void preHandle(HttpServletRequest request, Object handler, SpanCustomizer customizer) { if (WebMvcRuntime.get().isHandlerMethod(handler)) { HandlerMethod handlerMethod = ((HandlerMethod) handler); customizer.tag(CONTROLLER_CLASS, handlerMethod.getBeanType().getSimpleName()); customizer.tag(CONTROLLER_METHOD, handlerMethod.getMethod().getName()); } else { customizer.tag(CONTROLLER_CLASS, handler.getClass().getSimpleName()); } } HandlerParser();  static final HandlerParser NOOP; static final String CONTROLLER_CLASS; static final String CONTROLLER_METHOD; }
@Test public void preHandle_HandlerMethod_addsClassAndMethodTags() throws Exception { parser.preHandle( request, new HandlerMethod(controller, TestController.class.getMethod("items", String.class)), customizer ); verify(customizer).tag("mvc.controller.class", "TestController"); verify(customizer).tag("mvc.controller.method", "items"); verifyNoMoreInteractions(request, customizer); }
@Test public void preHandle_Handler_addsClassTag() { parser.preHandle(request, controller, customizer); verify(customizer).tag("mvc.controller.class", "TestController"); verifyNoMoreInteractions(request, customizer); }
@Test public void preHandle_NOOP_addsNothing() { HandlerParser.NOOP.preHandle(request, controller, customizer); verifyNoMoreInteractions(request, customizer); }