congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JettyEventListenerProxy
Code IndexAdd Tabnine to your IDE (free)

How to use
JettyEventListenerProxy
in
rocks.inspectit.agent.java.tracing.core.adapter.http.proxy

Best Java code snippets using rocks.inspectit.agent.java.tracing.core.adapter.http.proxy.JettyEventListenerProxy (Showing top 13 results out of 315)

origin: inspectIT/inspectIT

  @Test
  public void listenerProvided() {
    Object originalListener = new Object();
    proxy = new JettyEventListenerProxy(originalListener, spanStore);
    Object[] args = proxy.getProxyConstructorArguments();
    assertThat(args, is(new Object[] { originalListener, Boolean.TRUE }));
  }
}
origin: inspectIT/inspectIT

  @Test
  public void happyPath() throws IOException {
    int status = 200;
    proxy.onResponseStatus("version", status, "reason");
    verifyZeroInteractions(spanStore);
    assertThat(proxy.getStatus(), is(status));
  }
}
origin: inspectIT/inspectIT

/**
 * Connection failed.
 *
 * @param ex
 *            Throwable
 */
@ProxyMethod(parameterTypes = "java.lang.Throwable")
public void onConnectionFailed(Throwable ex) {
  handleThrowable(ex);
  if (null != originalListener) {
    WHttpEventListenerWrapper.ON_CONNECTION_FAILED.call(originalListener, ex);
  }
}
origin: inspectIT/inspectIT

@BeforeMethod
public void init() {
  // can not use @InjectMocks as span store gets injected to listener place
  proxy = new JettyEventListenerProxy(null, spanStore);
}
origin: inspectIT/inspectIT

@Test
public void spanStoreListenerNull() {
  Proxy proxyListener = new Proxy();
  when(httpExchange.getEventListener()).thenReturn(null);
  when(runtimeLinker.createProxy(eq(JettyEventListenerProxy.class), Mockito.<JettyEventListenerProxy> any(), Mockito.<ClassLoader> any())).thenReturn(proxyListener);
  AsyncClientRequestAdapter<TextMap> adapter = sensor.getAsyncClientRequestAdapter(object, new Object[] { httpExchange }, rsc);
  adapter.getSpanStoreAdapter().setSpanStore(spanStore);
  verify(httpExchange).setEventListener(proxyListener);
  ArgumentCaptor<JettyEventListenerProxy> proxyCaptor = ArgumentCaptor.forClass(JettyEventListenerProxy.class);
  verify(runtimeLinker).createProxy(eq(JettyEventListenerProxy.class), proxyCaptor.capture(), eq(httpExchange.getClass().getClassLoader()));
  assertThat(proxyCaptor.getValue().getOriginalListener(), is(nullValue()));
  assertThat(proxyCaptor.getValue().getSpanStore(), is(spanStore));
  verifyNoMoreInteractions(runtimeLinker);
  verifyZeroInteractions(object, rsc);
}
origin: inspectIT/inspectIT

  @Test
  public void happyPath() throws IOException {
    int status = 200;
    proxy.onResponseStatus("version", status, "reason");
    // can not be called before status reporting
    proxy.onResponseComplete();
    ArgumentCaptor<TagsProvidingAdapter> captor = ArgumentCaptor.forClass(TagsProvidingAdapter.class);
    verify(spanStore).finishSpan(captor.capture());
    TagsProvidingAdapter adapter = captor.getValue();
    assertThat(adapter, is(instanceOf(HttpResponseAdapter.class)));
    assertThat(adapter.getTags(), hasEntry(Tags.HTTP_STATUS.getKey(), String.valueOf(status)));
  }
}
origin: inspectIT/inspectIT

@Test
public void listenerNull() {
  Object[] args = proxy.getProxyConstructorArguments();
  assertThat(args, is(new Object[] { null, Boolean.FALSE }));
}
origin: inspectIT/inspectIT

  @Test
  public void happyPath() throws IOException {
    proxy.onRequestCommitted();
    verify(spanStore).startSpan();
  }
}
origin: inspectIT/inspectIT

  @Test
  public void happyPath() throws IOException {
    IOException ex = new IOException();
    proxy.onConnectionFailed(ex);
    ArgumentCaptor<TagsProvidingAdapter> captor = ArgumentCaptor.forClass(TagsProvidingAdapter.class);
    verify(spanStore).finishSpan(captor.capture());
    TagsProvidingAdapter adapter = captor.getValue();
    assertThat(adapter, is(instanceOf(ThrowableAwareResponseAdapter.class)));
    assertThat(adapter.getTags(), hasEntry(Tags.ERROR.getKey(), String.valueOf(true)));
    assertThat(adapter.getTags(), hasEntry(ExtraTags.THROWABLE_TYPE, ex.getClass().getSimpleName()));
  }
}
origin: inspectIT/inspectIT

  @Test
  public void happyPath() throws IOException {
    IOException ex = new IOException();
    proxy.onException(ex);
    ArgumentCaptor<TagsProvidingAdapter> captor = ArgumentCaptor.forClass(TagsProvidingAdapter.class);
    verify(spanStore).finishSpan(captor.capture());
    TagsProvidingAdapter adapter = captor.getValue();
    assertThat(adapter, is(instanceOf(ThrowableAwareResponseAdapter.class)));
    assertThat(adapter.getTags(), hasEntry(Tags.ERROR.getKey(), String.valueOf(true)));
    assertThat(adapter.getTags(), hasEntry(ExtraTags.THROWABLE_TYPE, ex.getClass().getSimpleName()));
  }
}
origin: inspectIT/inspectIT

/**
 * {@inheritDoc}
 */
@Override
public void setSpanStore(SpanStore spanStore) {
  // get original request listener
  Object originalListener = cache.invokeMethod(jettyHttpExchange.getClass(), "getEventListener", new Class<?>[] {}, jettyHttpExchange, new Object[] {}, null);
  // create proxy for this listener
  JettyEventListenerProxy listenerProxy = new JettyEventListenerProxy(originalListener, spanStore);
  Object proxyObject = runtimeLinker.createProxy(JettyEventListenerProxy.class, listenerProxy, jettyHttpExchange.getClass().getClassLoader());
  // find the interface event listener interface, it's in the super-class of the proxy
  Class<?> eventListenerClass = proxyObject.getClass().getSuperclass().getInterfaces()[0];
  // replace with our listener
  cache.invokeMethod(jettyHttpExchange.getClass(), "setEventListener", new Class<?>[] { eventListenerClass }, jettyHttpExchange, new Object[] { proxyObject }, null);
}
origin: inspectIT/inspectIT

@Test
public void spanStore() {
  Object listener = new Object();
  Proxy proxyListener = new Proxy();
  when(httpExchange.getEventListener()).thenReturn(listener);
  when(runtimeLinker.createProxy(eq(JettyEventListenerProxy.class), Mockito.<JettyEventListenerProxy> any(), Mockito.<ClassLoader> any())).thenReturn(proxyListener);
  AsyncClientRequestAdapter<TextMap> adapter = sensor.getAsyncClientRequestAdapter(object, new Object[] { httpExchange }, rsc);
  adapter.getSpanStoreAdapter().setSpanStore(spanStore);
  verify(httpExchange).setEventListener(proxyListener);
  ArgumentCaptor<JettyEventListenerProxy> proxyCaptor = ArgumentCaptor.forClass(JettyEventListenerProxy.class);
  verify(runtimeLinker).createProxy(eq(JettyEventListenerProxy.class), proxyCaptor.capture(), eq(httpExchange.getClass().getClassLoader()));
  assertThat(proxyCaptor.getValue().getOriginalListener(), is(listener));
  assertThat(proxyCaptor.getValue().getSpanStore(), is(spanStore));
  verifyNoMoreInteractions(runtimeLinker);
  verifyZeroInteractions(object, rsc);
}
origin: inspectIT/inspectIT

/**
 * Exception occurred.
 *
 * @param ex
 *            Throwable
 */
@ProxyMethod(parameterTypes = "java.lang.Throwable")
public void onException(Throwable ex) {
  handleThrowable(ex);
  if (null != originalListener) {
    WHttpEventListenerWrapper.ON_EXCEPTION.call(originalListener, ex);
  }
}
rocks.inspectit.agent.java.tracing.core.adapter.http.proxyJettyEventListenerProxy

Javadoc

The proxy of the Jetty request event listener. This proxy extends the org.eclipse.jetty.client.HttpEventListenerWrapper object and intercepts methods that are interesting for the manipulation of the span responsible for this request. All calls are delegated also to the original listener.

Currently we have the following interception points:

  • onRequestCommitted() - start the span
  • onResponseStatus() - capture the response status
  • onResponseComplete() - finish the span
  • onConnectionFailed() and onException() - handle the exceptional situations

Most used methods

  • <init>
  • getOriginalListener
    Gets #originalListener.
  • getProxyConstructorArguments
  • getSpanStore
    Gets #spanStore.
  • getStatus
  • handleThrowable
    Handling exceptional situations.
  • onConnectionFailed
    Connection failed.
  • onException
    Exception occurred.
  • onRequestCommitted
    Request committed event. This is earliest place we can start a span.
  • onResponseComplete
    Response complete event. We can finish span here.
  • onResponseStatus
    Response status event. We can capture status here.
  • onResponseStatus

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • addToBackStack (FragmentTransaction)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Runner (org.openjdk.jmh.runner)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now