Codota Logo
RequestNameHandlerInterceptorAdapter
Code IndexAdd Codota to your IDE (free)

How to use
RequestNameHandlerInterceptorAdapter
in
com.microsoft.applicationinsights.web.spring

Best Java code snippets using com.microsoft.applicationinsights.web.spring.RequestNameHandlerInterceptorAdapter (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: com.microsoft.azure/applicationinsights-web

  @Override
  public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
    registry.addInterceptor(new RequestNameHandlerInterceptorAdapter());
  }
}
origin: com.microsoft.azure/applicationinsights-web

/**
 * This method is being invoked just before the request is forwarded the the relevant controller.
 * It should always return true, so the request will be processed in any case of failure.
 */
@Override
public boolean preHandle(HttpServletRequest request,
             HttpServletResponse response,
             Object handler) throws Exception {
  try {
    RequestTelemetryContext context = ThreadContext.getRequestTelemetryContext();
    if (context == null) {
      return true;
    }
    String requestName = generateRequestName(request, handler);
    if (requestName == null) {
      return true;
    }
    context.getHttpRequestTelemetry().setName(requestName);
  } catch (Exception e) {
    InternalLogger.INSTANCE.error(
      "Failed to invoke interceptor '%s' with exception: %s.",
      this.getClass().getSimpleName(),
      e.toString());
  }
  return true;
}
origin: Microsoft/ApplicationInsights-Java

@Test
public void testAdapterReturnTrueWhenExceptionIsThrown() throws Exception {
  HttpServletRequest request = mock(HttpServletRequest.class);
  Mockito.doAnswer(new Answer() {
    @Override
    public Object answer(InvocationOnMock invocation) throws Throwable {
      throw new Exception("FATAL!");
    }
  }).when(request).getMethod();
  boolean result = interceptorAdapter.preHandle(request, null, handlerMethod);
  Assert.assertTrue("Adapter should return true.", result);
}
origin: Microsoft/ApplicationInsights-Java

/**
 * This method is being invoked just before the request is forwarded the the relevant controller.
 * It should always return true, so the request will be processed in any case of failure.
 */
@Override
public boolean preHandle(HttpServletRequest request,
             HttpServletResponse response,
             Object handler) throws Exception {
  try {
    RequestTelemetryContext context = ThreadContext.getRequestTelemetryContext();
    if (context == null) {
      return true;
    }
    String requestName = generateRequestName(request, handler);
    if (requestName == null) {
      return true;
    }
    context.getHttpRequestTelemetry().setName(requestName);
  } catch (Exception e) {
    InternalLogger.INSTANCE.error(
      "Failed to invoke interceptor '%s' with exception: %s.",
      this.getClass().getSimpleName(),
      e.toString());
  }
  return true;
}
origin: Microsoft/ApplicationInsights-Java

@Test
public void testAdapterSetRequestNameCorrectly() throws Exception {
  HttpServletRequest request = mock(HttpServletRequest.class);
  when(request.getMethod()).thenReturn(HttpMethods.GET);
  interceptorAdapter.preHandle(request, null, handlerMethod);
  String requestName = ThreadContext.getRequestTelemetryContext().getHttpRequestTelemetry().getName();
  String expectedRequestName =
      String.format("%s %s/%s", HttpMethods.GET, DEFAULT_CONTROLLER_NAME, DEFAULT_ACTION_NAME);
  Assert.assertEquals(expectedRequestName, requestName);
}
origin: Microsoft/ApplicationInsights-Java

  @Override
  public void addInterceptors(org.springframework.web.servlet.config.annotation.InterceptorRegistry registry) {
    registry.addInterceptor(new RequestNameHandlerInterceptorAdapter());
  }
}
origin: Microsoft/ApplicationInsights-Java

  @Test
  public void testAdapterReturnTrueWhenContextNull() throws Exception {
    ThreadContext.setRequestTelemetryContext(null);
    boolean result = interceptorAdapter.preHandle(null, null, handlerMethod);

    Assert.assertTrue("Adapter should return true.", result);
  }
}
com.microsoft.applicationinsights.web.springRequestNameHandlerInterceptorAdapter

Javadoc

Created by yonisha on 3/1/2015. This class intercepts all requests before forwarded to the relevant handler. It extracts the relevant controller and method names and updates the request telemetry name. This class should never throw exceptions to avoid blocking request processing.

Most used methods

  • <init>
  • generateRequestName
  • preHandle
    This method is being invoked just before the request is forwarded the the relevant controller. It sh

Popular in Java

  • Finding current android device location
  • getContentResolver (Context)
  • onRequestPermissionsResult (Fragment)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Join (org.hibernate.mapping)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now