Search in sources :

Example 1 with JettyAsyncListener

use of com.navercorp.pinpoint.plugin.jetty.JettyAsyncListener in project pinpoint by naver.

the class RequestStartAsyncInterceptor method after.

@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    if (isDebug) {
        logger.afterInterceptor(target, args, result, throwable);
    }
    final Trace trace = traceContext.currentTraceObject();
    if (trace == null) {
        return;
    }
    try {
        final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
        if (validate(target, result, throwable)) {
            // Add async listener. Servlet 3.0
            final AsyncContext asyncContext = (AsyncContext) result;
            final AsyncListener asyncListener = new JettyAsyncListener(this.traceContext, recorder.recordNextAsyncContext(true));
            asyncContext.addListener(asyncListener);
            if (isDebug) {
                logger.debug("Add async listener {}", asyncListener);
            }
        }
        recorder.recordServiceType(JettyConstants.JETTY_METHOD);
        recorder.recordApi(descriptor);
        recorder.recordException(throwable);
    } catch (Throwable t) {
        logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
    } finally {
        trace.traceBlockEnd();
    }
}
Also used : Trace(com.navercorp.pinpoint.bootstrap.context.Trace) JettyAsyncListener(com.navercorp.pinpoint.plugin.jetty.JettyAsyncListener) SpanEventRecorder(com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder) AsyncListener(javax.servlet.AsyncListener) JettyAsyncListener(com.navercorp.pinpoint.plugin.jetty.JettyAsyncListener) AsyncContext(javax.servlet.AsyncContext)

Aggregations

SpanEventRecorder (com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder)1 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)1 JettyAsyncListener (com.navercorp.pinpoint.plugin.jetty.JettyAsyncListener)1 AsyncContext (javax.servlet.AsyncContext)1 AsyncListener (javax.servlet.AsyncListener)1