@Test public void completeRequestSpan_does_nothing_if_listener_is_already_marked_completed() { implSpy.alreadyCompleted.set(true); assertThat(tracingStateSpan.isCompleted()).isFalse(); implSpy.completeRequestSpan(asyncEventMock); assertThat(tracingStateSpan.isCompleted()).isFalse(); assertThat(implSpy.alreadyCompleted.get()).isTrue(); }
@SuppressWarnings("deprecation") protected void completeRequestSpan(AsyncEvent event) { if (alreadyCompleted.getAndSet(true)) { return; } ServletRequest request = event.getSuppliedRequest(); ServletResponse response = event.getSuppliedResponse(); final HttpServletRequest httpRequest = (request instanceof HttpServletRequest) ? (HttpServletRequest) request : null; final HttpServletResponse httpResponse = (response instanceof HttpServletResponse) ? (HttpServletResponse) response : null; final Throwable error = event.getThrowable(); runnableWithTracing( new Runnable() { @Override public void run() { Span span = Tracer.getInstance().getCurrentSpan(); try { tagAndNamingStrategy.handleResponseTaggingAndFinalSpanName( span, httpRequest, httpResponse, error, tagAndNamingAdapter ); } finally { Tracer.getInstance().completeRequestSpan(); } } }, originalRequestTracingState ).run(); }
WingtipsRequestSpanCompletionAsyncListener implements AsyncListener { @SuppressWarnings("deprecation") protected void completeRequestSpan(AsyncEvent event) { if (alreadyCompleted.getAndSet(true)) { return; } ServletRequest request = event.getSuppliedRequest(); ServletResponse response = event.getSuppliedResponse(); final HttpServletRequest httpRequest = (request instanceof HttpServletRequest) ? (HttpServletRequest) request : null; final HttpServletResponse httpResponse = (response instanceof HttpServletResponse) ? (HttpServletResponse) response : null; final Throwable error = event.getThrowable(); runnableWithTracing( new Runnable() { @Override public void run() { Span span = Tracer.getInstance().getCurrentSpan(); try { tagAndNamingStrategy.handleResponseTaggingAndFinalSpanName( span, httpRequest, httpResponse, error, tagAndNamingAdapter ); } finally { Tracer.getInstance().completeRequestSpan(); } } }, originalRequestTracingState ).run(); } }
WingtipsRequestSpanCompletionAsyncListener implements AsyncListener { @SuppressWarnings("deprecation") protected void completeRequestSpan(AsyncEvent event) { if (alreadyCompleted.getAndSet(true)) { return; } ServletRequest request = event.getSuppliedRequest(); ServletResponse response = event.getSuppliedResponse(); final HttpServletRequest httpRequest = (request instanceof HttpServletRequest) ? (HttpServletRequest) request : null; final HttpServletResponse httpResponse = (response instanceof HttpServletResponse) ? (HttpServletResponse) response : null; final Throwable error = event.getThrowable(); runnableWithTracing( new Runnable() { @Override public void run() { Span span = Tracer.getInstance().getCurrentSpan(); try { tagAndNamingStrategy.handleResponseTaggingAndFinalSpanName( span, httpRequest, httpResponse, error, tagAndNamingAdapter ); } finally { Tracer.getInstance().completeRequestSpan(); } } }, originalRequestTracingState ).run(); } WingtipsRequestSpanCompletionAsyncListener(
        TracingState originalRequestTracingState,
        HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse> tagAndNamingAdapter
    ); }
WingtipsRequestSpanCompletionAsyncListener implements AsyncListener { @SuppressWarnings("deprecation") protected void completeRequestSpan(AsyncEvent event) { if (alreadyCompleted.getAndSet(true)) { return; } ServletRequest request = event.getSuppliedRequest(); ServletResponse response = event.getSuppliedResponse(); final HttpServletRequest httpRequest = (request instanceof HttpServletRequest) ? (HttpServletRequest) request : null; final HttpServletResponse httpResponse = (response instanceof HttpServletResponse) ? (HttpServletResponse) response : null; final Throwable error = event.getThrowable(); runnableWithTracing( new Runnable() { @Override public void run() { Span span = Tracer.getInstance().getCurrentSpan(); try { tagAndNamingStrategy.handleResponseTaggingAndFinalSpanName( span, httpRequest, httpResponse, error, tagAndNamingAdapter ); } finally { Tracer.getInstance().completeRequestSpan(); } } }, originalRequestTracingState ).run(); } WingtipsRequestSpanCompletionAsyncListener(
        TracingState originalRequestTracingState,
        HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse> tagAndNamingAdapter
    ); @Override void onComplete(AsyncEvent event); @Override void onTimeout(AsyncEvent event); @Override void onError(AsyncEvent event); @Override void onStartAsync(AsyncEvent event); }
WingtipsRequestSpanCompletionAsyncListener implements AsyncListener { @SuppressWarnings("deprecation") protected void completeRequestSpan(AsyncEvent event) { if (alreadyCompleted.getAndSet(true)) { return; } ServletRequest request = event.getSuppliedRequest(); ServletResponse response = event.getSuppliedResponse(); final HttpServletRequest httpRequest = (request instanceof HttpServletRequest) ? (HttpServletRequest) request : null; final HttpServletResponse httpResponse = (response instanceof HttpServletResponse) ? (HttpServletResponse) response : null; final Throwable error = event.getThrowable(); runnableWithTracing( new Runnable() { @Override public void run() { Span span = Tracer.getInstance().getCurrentSpan(); try { tagAndNamingStrategy.handleResponseTaggingAndFinalSpanName( span, httpRequest, httpResponse, error, tagAndNamingAdapter ); } finally { Tracer.getInstance().completeRequestSpan(); } } }, originalRequestTracingState ).run(); } WingtipsRequestSpanCompletionAsyncListener(
        TracingState originalRequestTracingState,
        HttpTagAndSpanNamingStrategy<HttpServletRequest, HttpServletResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpServletRequest, HttpServletResponse> tagAndNamingAdapter
    ); @Override void onComplete(AsyncEvent event); @Override void onTimeout(AsyncEvent event); @Override void onError(AsyncEvent event); @Override void onStartAsync(AsyncEvent event);  }