use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ChannelPipelineWriteInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (!validate(args)) {
return;
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(NettyConstants.SERVICE_TYPE);
// Inner handler can run before after() method.
// If create AsyncContext in after() method, then there is a possibility that AsyncContext will be saved later than execution
// The write method returns an exception in the Future, so you do not needs to worry about to handle throwable field.
Object request = ArrayUtils.get(args, 0);
if (isAsynchronousInvocation(request)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) request)._$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 DispatchInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, descriptor.getClassName(), descriptor.getMethodName(), descriptor.getParameterDescriptor(), args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
if (isCompletedContinuation(args)) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(serviceType);
AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 0, AsyncContextAccessor.class);
if (accessor != null) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
accessor._$PINPOINT$_setAsyncContext(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ResumeWithInterceptor method getAsyncContext.
private AsyncContext getAsyncContext(Object object) {
if (object instanceof Continuation) {
CoroutineContext context = ((Continuation<?>) object).getContext();
if (context instanceof AsyncContextAccessor) {
AsyncContextAccessor accessor = (AsyncContextAccessor) context;
AsyncContext asyncContext = accessor._$PINPOINT$_getAsyncContext();
return asyncContext;
}
}
return null;
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class ContextImplRunOnContextInterceptor method doInBeforeTrace.
@Override
protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
recorder.recordServiceType(VertxConstants.VERTX_INTERNAL);
if (validate(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 AsyncContextSpanEventEndPointInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final AsyncContext asyncContext = getAsyncContext(target);
if (asyncContext == null) {
logger.debug("AsyncContext not found");
return;
}
final Trace trace = getAsyncTrace(asyncContext);
if (trace == null) {
return;
}
if (isDebug) {
logger.debug("Asynchronous invocation. asyncTraceId={}, trace={}", asyncContext, trace);
}
// entry scope.
entryAsyncTraceScope(trace);
try {
// trace event for default & async.
final SpanEventRecorder recorder = trace.traceBlockBegin();
doInBeforeTrace(recorder, asyncContext, target, args);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations