use of com.navercorp.pinpoint.plugin.tomcat.TomcatAsyncListener 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)) {
com.navercorp.pinpoint.bootstrap.context.AsyncContext nextAsyncContext = recorder.recordNextAsyncContext(true);
// Add async listener
final AsyncContext asyncContext = (AsyncContext) result;
final AsyncListener asyncListener = new TomcatAsyncListener(this.traceContext, nextAsyncContext);
asyncContext.addListener(asyncListener);
// Set AsyncContext, AsyncListener
final HttpServletRequest request = (HttpServletRequest) target;
request.setAttribute(com.navercorp.pinpoint.bootstrap.context.AsyncContext.class.getName(), nextAsyncContext);
request.setAttribute(TomcatConstants.TOMCAT_SERVLET_REQUEST_TRACE, asyncListener);
if (isDebug) {
logger.debug("Add async listener {}", asyncListener);
}
}
recorder.recordServiceType(TomcatConstants.TOMCAT_METHOD);
recorder.recordApi(descriptor);
recorder.recordException(throwable);
} catch (Throwable t) {
logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
Aggregations