use of com.navercorp.pinpoint.plugin.resttemplate.field.accessor.TraceFutureFlagAccessor in project pinpoint by naver.
the class AsyncHttpRequestInterceptor method traceAndRecordFuture.
// reason for virtual Method
// //////////////////////////////////////////////////
// 1. if virtualMethod not crated
// executeAsync
// - Asynchronous Invocation (for future set)
// - some trace (like connect, write, etc ...)
// //////////////////////////
// 2. if virtualMethod crated
// executeAsync
//
// - some trace (like connect, write, etc ...)
// - Asynchronous Invocation (for future set)
// //////////////////////////////////////////////////
private void traceAndRecordFuture(Object result, Throwable throwable) {
if (throwable != null) {
return;
}
if (!(result instanceof ListenableFuture)) {
return;
}
final Trace virtualMethodTrace = traceContext.currentTraceObject();
try {
SpanEventRecorder recorder = virtualMethodTrace.traceBlockBegin();
recorder.recordServiceType(RestTemplateConstants.SERVICE_TYPE);
recorder.recordApi(execAsyncResultMethodDescriptor);
if (isAsynchronousInvocation(result)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}", asyncContext);
}
if (result instanceof TraceFutureFlagAccessor) {
((TraceFutureFlagAccessor) result)._$PINPOINT$_setTraceFlag(true);
}
}
} finally {
virtualMethodTrace.traceBlockEnd();
}
}
Aggregations