use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor 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.async.AsyncContextAccessor 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.async.AsyncContextAccessor in project pinpoint by naver.
the class DirectivesInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
int requestContextIndex = getArgsIndexOfRequestContext(args);
if (requestContextIndex == -1) {
return;
}
if (traceContext.currentTraceObject() != null) {
return;
}
RequestContextImpl requestContext = (RequestContextImpl) args[requestContextIndex];
if (!(requestContext instanceof AsyncContextAccessor)) {
if (isDebug) {
logger.debug("Invalid requestContext. Need metadata accessor({}).", AsyncContextAccessor.class.getName());
}
return;
}
akka.http.scaladsl.model.HttpRequest request = requestContext.request();
final Trace trace = createTrace(request);
if (trace == null || !trace.canSampled()) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(AkkaHttpConstants.AKKA_HTTP_SERVER_INTERNAL);
final AsyncContext asyncContext = recorder.recordNextAsyncContext(true);
((AsyncContextAccessor) requestContext)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set closeable-AsyncContext {}", asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class DeliveryConstructInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT_INTERNAL);
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
if (target instanceof AsyncContextAccessor) {
AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class ChannelOperationsOnInboundCompleteMethodInterceptor method doInBeforeTrace.
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
if (((ChannelOperations) target).receiveObject() instanceof AsyncContextAccessor) {
AsyncContextAccessor asyncContextAccessor = (AsyncContextAccessor) ((ChannelOperations) target).receiveObject();
asyncContextAccessor._$PINPOINT$_setAsyncContext(asyncContext);
}
}
Aggregations