use of com.navercorp.pinpoint.plugin.tomcat.AsyncAccessor in project pinpoint by naver.
the class RequestRecycleInterceptor method before.
@Override
public void before(Object target, Object[] args) {
logger.beforeInterceptor(target, target.getClass().getName(), targetMethod.getName(), "", args);
try {
if (target instanceof AsyncAccessor) {
// reset
((AsyncAccessor) target)._$PINPOINT$_setAsync(Boolean.FALSE);
}
if (target instanceof TraceAccessor) {
final Trace trace = ((TraceAccessor) target)._$PINPOINT$_getTrace();
if (trace != null && trace.canSampled()) {
// end of root span
trace.close();
}
// reset
((TraceAccessor) target)._$PINPOINT$_setTrace(null);
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.plugin.tomcat.AsyncAccessor 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, "", descriptor.getMethodName(), "", args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (validate(target, result, throwable)) {
((AsyncAccessor) target)._$PINPOINT$_setAsync(Boolean.TRUE);
// make asynchronous trace-id
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// result is BasicFuture
// type check validate()
((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
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