use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor 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.async.AsyncContextAccessor 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.async.AsyncContextAccessor 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.async.AsyncContextAccessor in project pinpoint by naver.
the class HttpClientImplDoRequestInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
HttpClientRequest resultToRequest = null;
if (validate(result)) {
resultToRequest = (HttpClientRequest) result;
}
final HttpClientRequest request = resultToRequest;
if (!trace.canSampled()) {
if (request != null) {
requestTraceWriter.write(request);
}
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
recorder.recordServiceType(VertxConstants.VERTX_HTTP_CLIENT_INTERNAL);
final String hostAndPort = toHostAndPort(args);
if (hostAndPort != null) {
recorder.recordAttribute(AnnotationKey.HTTP_INTERNAL_DISPLAY, hostAndPort);
if (isDebug) {
logger.debug("Set hostAndPort {}", hostAndPort);
}
}
if (request != null) {
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) request)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set asyncContext {}", asyncContext);
}
}
} finally {
trace.traceBlockEnd();
}
}
Aggregations