Codota Logo
JettyEventListenerProxy
Code IndexAdd Codota 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)

  • 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: 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 requests using okhttp
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • String (java.lang)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
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