Tabnine Logo
WingtipsRequestSpanCompletionAsyncListener
Code IndexAdd Tabnine to your IDE (free)

How to use
WingtipsRequestSpanCompletionAsyncListener
in
com.nike.wingtips.servlet

Best Java code snippets using com.nike.wingtips.servlet.WingtipsRequestSpanCompletionAsyncListener (Showing top 14 results out of 315)

origin: Nike-Inc/wingtips

@Override
public void setupTracingCompletionWhenAsyncRequestCompletes(
  HttpServletRequest asyncRequest,
  HttpServletResponse asyncResponse,
  TracingState originalRequestTracingState,
  HttpTagAndSpanNamingStrategy<HttpServletRequest,HttpServletResponse> tagAndNamingStrategy,
  HttpTagAndSpanNamingAdapter<HttpServletRequest,HttpServletResponse> tagAndNamingAdapter
) {
  // Async processing was started, so we have to complete it with a listener.
  asyncRequest.getAsyncContext().addListener(
    new WingtipsRequestSpanCompletionAsyncListener(
      originalRequestTracingState, tagAndNamingStrategy, tagAndNamingAdapter
    ),
    asyncRequest,
    asyncResponse
  );
}
origin: Nike-Inc/wingtips

@Test
public void onComplete_calls_completeRequestSpan_and_does_nothing_else() {
  // when
  implSpy.onComplete(asyncEventMock);
  // then
  verify(implSpy).onComplete(asyncEventMock);
  verify(implSpy).completeRequestSpan(asyncEventMock);
  verifyNoMoreInteractions(implSpy);
}
origin: Nike-Inc/wingtips

@Test
public void onError_does_nothing() {
  // when
  implSpy.onError(asyncEventMock);
  // then
  verify(implSpy).onError(asyncEventMock);
  verifyNoMoreInteractions(implSpy);
  verifyZeroInteractions(asyncEventMock);
}
origin: Nike-Inc/wingtips

@Override
public void onComplete(AsyncEvent event) {
  completeRequestSpan(event);
}
origin: Nike-Inc/wingtips

@Test
public void onStartAsync_does_nothing_if_asyncEvent_has_null_AsyncContext() {
  // given
  // This should never happen in reality, but we protect against null pointer exceptions anyway.
  doReturn(null).when(asyncEventMock).getAsyncContext();
  // when
  implSpy.onStartAsync(asyncEventMock);
  // then
  verify(implSpy).onStartAsync(asyncEventMock);
  verifyNoMoreInteractions(implSpy);
}
origin: Nike-Inc/wingtips

@Test
public void onTimeout_does_nothing() {
  // when
  implSpy.onTimeout(asyncEventMock);
  // then
  verify(implSpy).onTimeout(asyncEventMock);
  verifyNoMoreInteractions(implSpy);
  verifyZeroInteractions(asyncEventMock);
}
origin: Nike-Inc/wingtips

@Test
public void completeRequestSpan_does_nothing_if_listener_is_already_marked_completed() {
  // given
  implSpy.alreadyCompleted.set(true);
  assertThat(tracingStateSpan.isCompleted()).isFalse();
  // when
  implSpy.completeRequestSpan(asyncEventMock);
  // then
  assertThat(tracingStateSpan.isCompleted()).isFalse();
  assertThat(implSpy.alreadyCompleted.get()).isTrue();
}

origin: Nike-Inc/wingtips

@Test
public void onStartAsync_propagates_the_listener_to_the_new_AsyncContext() {
  // given
  AsyncContext asyncContextMock = mock(AsyncContext.class);
  doReturn(asyncContextMock).when(asyncEventMock).getAsyncContext();
  // when
  implSpy.onStartAsync(asyncEventMock);
  // then
  verify(asyncContextMock).addListener(implSpy, requestMock, responseMock);
}
origin: Nike-Inc/wingtips

@Test
public void constructor_sets_fields_as_expected() {
  // given
  TracingState tracingStateMock = mock(TracingState.class);
  // when
  WingtipsRequestSpanCompletionAsyncListener impl =
    new WingtipsRequestSpanCompletionAsyncListener(tracingStateMock, tagAndNamingStrategy, tagAndNamingAdapterMock);
  // then
  assertThat(impl.originalRequestTracingState).isSameAs(tracingStateMock);
  assertThat(impl.tagAndNamingStrategy).isSameAs(tagAndNamingStrategy);
  assertThat(impl.tagAndNamingAdapter).isSameAs(tagAndNamingAdapterMock);
  assertThat(impl.alreadyCompleted.get()).isFalse();
}
origin: Nike-Inc/wingtips

@Test
public void completeRequestSpan_marks_listener_as_completed_even_if_unexpected_exception_occurs() {
  // given
  Tracer.getInstance().startRequestWithRootSpan("someOtherUnrelatedSpan");
  TracingState unrelatedThreadTracingState = TracingState.getCurrentThreadTracingState();
  final RuntimeException expectedExplosion = new RuntimeException("kaboom");
  SpanRecorder explodingSpanRecorder = new SpanRecorder() {
    @Override
    public void spanCompleted(Span span) {
      throw expectedExplosion;
    }
  };
  Tracer.getInstance().addSpanLifecycleListener(explodingSpanRecorder);
  assertThat(implSpy.alreadyCompleted.get()).isFalse();
  // when
  Throwable actualEx = catchThrowable(() -> implSpy.completeRequestSpan(asyncEventMock));
  // then
  assertThat(actualEx).isSameAs(expectedExplosion);
  assertThat(explodingSpanRecorder.completedSpans).hasSize(0);
  assertThat(implSpy.alreadyCompleted.get()).isTrue();
  // Tracing state got reset back to original from when the method was called.
  assertThat(TracingState.getCurrentThreadTracingState()).isEqualTo(unrelatedThreadTracingState);
}
origin: Nike-Inc/wingtips

@Test
public void constructor_uses_default_NoOpHttpTagAdapter_if_passed_null_tag_adapter() {
  // when
  WingtipsRequestSpanCompletionAsyncListener impl =
    new WingtipsRequestSpanCompletionAsyncListener(tracingState, tagAndNamingStrategy, null);
  // then
  assertThat(impl.tagAndNamingAdapter).isSameAs(NoOpHttpTagAdapter.getDefaultInstance());
  assertThat(impl.originalRequestTracingState).isSameAs(tracingState);
  assertThat(impl.tagAndNamingStrategy).isSameAs(tagAndNamingStrategy);
}
origin: Nike-Inc/wingtips

implSpy.completeRequestSpan(asyncEventMock);
origin: Nike-Inc/wingtips

@Test
public void constructor_uses_default_NoOpHttpTagStrategy_if_passed_null_tag_strategy() {
  // when
  WingtipsRequestSpanCompletionAsyncListener impl =
    new WingtipsRequestSpanCompletionAsyncListener(tracingState, null, tagAndNamingAdapterMock);
  // then
  assertThat(impl.tagAndNamingStrategy).isSameAs(NoOpHttpTagStrategy.getDefaultInstance());
  assertThat(impl.originalRequestTracingState).isSameAs(tracingState);
  assertThat(impl.tagAndNamingAdapter).isSameAs(tagAndNamingAdapterMock);
}
origin: Nike-Inc/wingtips

  new WingtipsRequestSpanCompletionAsyncListener(tracingState, tagAndNamingStrategy, tagAndNamingAdapterMock)
);
asyncEventMock = mock(AsyncEvent.class);
com.nike.wingtips.servletWingtipsRequestSpanCompletionAsyncListener

Javadoc

Helper class for Servlet3Runtime that implements AsyncListener, whose job is to complete the overall request span when an async servlet request finishes. You should not need to worry about this class - it is an internal implementation detail for Servlet3Runtime.

Most used methods

  • <init>
  • completeRequestSpan
    Does the work of doing the final span tagging and naming, and completes the span for #originalReques
  • onComplete
  • onError
  • onStartAsync
  • onTimeout

Popular in Java

  • Creating JSON documents from java classes using gson
  • notifyDataSetChanged (ArrayAdapter)
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Best plugins for Eclipse
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