use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ParallelWorkerConstructorInterceptor method after.
public void after(Object target, Object[] arg, Object result, Throwable throwable) {
AsyncContext asyncContext = (AsyncContext) scope.getCurrentInvocation().getAttachment();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ChannelPromiseAddListenerInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
if (isAsynchronousInvocation(target, args, result, throwable)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$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 HttpEncoderInterceptor method afterAsync.
private void afterAsync(Object target, Object[] args, Object result, Throwable throwable) {
final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 1);
if (asyncContext == null) {
logger.debug("AsyncContext not found");
return;
}
final Trace trace = asyncContext.currentAsyncTraceObject();
if (trace == null) {
return;
}
// leave scope.
if (!leaveAsyncTraceScope(trace)) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to leave scope of async trace {}.", trace);
}
// delete unstable trace.
deleteAsyncContext(trace, asyncContext);
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)) {
deleteAsyncContext(trace, asyncContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class HttpEncoderInterceptor method beforeAsync.
private void beforeAsync(Object target, Object[] args) {
((AsyncStartFlagFieldAccessor) args[1])._$PINPOINT$_setAsyncStartFlag(true);
final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 1);
if (asyncContext == null) {
logger.debug("AsyncContext not found");
return;
}
final Trace trace = getAsyncTrace(asyncContext);
if (trace == null) {
return;
}
// entry scope.
entryAsyncTraceScope(trace);
try {
// trace event for default & async.
final SpanEventRecorder recorder = trace.traceBlockBegin();
doInBeforeTrace(recorder, trace, target, args);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class MongoRSessionInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
if (collectJson) {
final boolean success = InterceptorUtils.isSuccess(throwable);
if (success) {
if (args != null) {
NormalizedBson parsedBson = MongoUtil.parseBson(args, traceBsonBindValue);
MongoUtil.recordParsedBson(recorder, parsedBson);
}
}
}
recorder.recordException(throwable);
if (isAsynchronousInvocation(target, args, result, throwable)) {
// Trace to Disposable object
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}, result={}", asyncContext, result);
}
}
}
Aggregations