use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HttpClientHandlerRequestWithBodyInterceptor method doInBeforeTrace.
@Override
public void doInBeforeTrace(SpanEventRecorder recorder, AsyncContext asyncContext, Object target, Object[] args) {
if (ArrayUtils.isEmpty(args)) {
// Skip
return;
}
// Set HttpClientOptions
if (args[0] instanceof AsyncContextAccessor) {
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
}
// Set hostname
if (args[0] instanceof ChannelOperations) {
try {
final ChannelOperations channelOperations = (ChannelOperations) args[0];
final InetSocketAddress inetSocketAddress = (InetSocketAddress) channelOperations.channel().remoteAddress();
if (inetSocketAddress != null) {
final String hostName = SocketAddressUtils.getHostNameFirst(inetSocketAddress);
if (hostName != null) {
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, HostAndPort.toHostAndPortString(hostName, inetSocketAddress.getPort()));
}
}
} catch (Exception ignore) {
}
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class SchedulerAndWorkerScheduleMethodInterceptor method doInAfterTrace.
// Disposable schedule(Runnable task);
// Disposable schedule(Runnable task, long delay, TimeUnit unit)
// Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit)
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
recorder.recordServiceType(ReactorConstants.REACTOR_NETTY);
if (isAsynchronousInvocation(target, args, result, throwable)) {
// Trace to Disposable object
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class LettuceMethodInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
final String endPoint = toEndPoint(target);
recorder.recordApi(getMethodDescriptor());
recorder.recordEndPoint(endPoint != null ? endPoint : "Unknown");
recorder.recordDestinationId(LettuceConstants.REDIS_LETTUCE.getName());
recorder.recordServiceType(LettuceConstants.REDIS_LETTUCE);
recorder.recordException(throwable);
if (result instanceof AsyncContextAccessor) {
if (AsyncContextAccessorUtils.getAsyncContext(result) == null) {
// Avoid duplicate async context
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
}
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HttpTcpClientConnectInterceptor method doInAfterTrace.
@Override
public void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) throws Exception {
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
recorder.recordServiceType(ReactorNettyConstants.REACTOR_NETTY_CLIENT_INTERNAL);
if (result instanceof AsyncContextAccessor) {
// Set MonoHttpConnect
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$PINPOINT$_setAsyncContext(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor 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);
}
Aggregations