use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class DispatchHandlerInvokeHandlerMethodInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordServiceType(SpringWebFluxConstants.SPRING_WEBFLUX);
recorder.recordException(throwable);
if (Boolean.FALSE == validate(args)) {
return;
}
final AsyncContext publisherAsyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
if (publisherAsyncContext != null) {
// Set AsyncContext to CoreSubscriber
if (result instanceof AsyncContextAccessor) {
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(publisherAsyncContext);
if (isDebug) {
logger.debug("Set AsyncContext result={}", result);
}
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class DispatchHandlerHandleMethodInterceptor method doInBeforeTrace.
@Override
protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
if (isAsync(args)) {
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}", asyncContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ExchangeFunctionMethodInterceptor method doInBeforeTrace.
@Override
protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
if (isAsync(args)) {
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set closeable-AsyncContext {}", asyncContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext 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();
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class AsyncContextSpanEventEndPointInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final AsyncContext asyncContext = getAsyncContext(target);
if (asyncContext == null) {
logger.debug("Not found asynchronous invocation metadata");
return;
}
if (isDebug) {
logger.debug("Asynchronous invocation. asyncContext={}", asyncContext);
}
final Trace trace = asyncContext.currentAsyncTraceObject();
if (trace == null) {
return;
}
if (isDebug) {
logger.debug("Asynchronous invocation. asyncTraceId={}, trace={}", asyncContext, trace);
}
// leave scope.
if (!leaveAsyncTraceScope(trace)) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to leave scope of async trace {}.", trace);
}
// delete unstable trace.
deleteAsyncTrace(trace);
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
doInAfterTrace(recorder, target, args, result, throwable);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
if (isAsyncTraceDestination(trace)) {
if (isDebug) {
logger.debug("Arrived at async trace destination. asyncTraceId={}", asyncContext);
}
deleteAsyncTrace(trace);
}
finishAsyncState(asyncContext);
}
}
Aggregations