use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class MongoCUDSessionInterceptor 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);
}
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class ScheduleResumeInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, descriptor.getClassName(), descriptor.getMethodName(), descriptor.getParameterDescriptor(), args);
}
final Continuation continuation = getContinuation(args);
if (continuation == null) {
return;
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
final AsyncContextAccessor asyncContextAccessor = getAsyncContextAccessor(continuation);
if (asyncContextAccessor != null) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
asyncContextAccessor._$PINPOINT$_setAsyncContext(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class DefaultClientExchangeHandlerImplStartMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
final HttpRequest httpRequest = getHttpRequest(target);
final NameIntValuePair<String> host = getHost(target);
final boolean sampling = trace.canSampled();
if (!sampling) {
if (httpRequest != null) {
this.requestTraceWriter.write(httpRequest);
}
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
// set remote trace
final TraceId nextId = trace.getTraceId().getNextTraceId();
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(HttpClient4Constants.HTTP_CLIENT_4);
if (httpRequest != null) {
final String hostString = getHostString(host.getName(), host.getValue());
this.requestTraceWriter.write(httpRequest, nextId, hostString);
}
try {
if (isAsynchronousInvocation(target, args)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
// check type isAsynchronousInvocation()
((AsyncContextAccessor) ((ResultFutureGetter) target)._$PINPOINT$_getResultFuture())._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set AsyncContext {}", asyncContext);
}
}
} catch (Throwable t) {
logger.warn("Failed to BEFORE process. {}", t.getMessage(), t);
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HystrixObservableTimeoutOperatorCallInterceptor method doInBeforeTrace.
@Override
protected void doInBeforeTrace(SpanEventRecorder recorder, Object target, Object[] args) {
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 RabbitMQConsumerDispatchInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (!validate(target, args)) {
return;
}
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
final Trace trace = createTrace(target, args);
if (trace == null) {
return;
}
if (!trace.canSampled()) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(RabbitMQClientConstants.RABBITMQ_CLIENT_INTERNAL);
// args[2] would be com.rabbitmq.client.Envelope, implementing AsyncContextAccessor via plugin
AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 2, AsyncContextAccessor.class);
if (accessor != null) {
AsyncContext asyncContext = recorder.recordNextAsyncContext();
accessor._$PINPOINT$_setAsyncContext(asyncContext);
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations