use of com.navercorp.pinpoint.bootstrap.context.AsyncContext 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);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class WrappedAsyncSpanEventRecorder method recordNextAsyncContext.
@Override
public AsyncContext recordNextAsyncContext(boolean asyncStateSupport) {
if (asyncStateSupport) {
final TraceRoot traceRoot = this.traceRoot;
final AsyncId asyncIdObject = getNextAsyncId();
final boolean isDisabled = isOverflowState();
final AsyncState asyncState = this.asyncState;
asyncState.setup();
final AsyncContext asyncContext = asyncContextFactory.newAsyncContext(traceRoot, asyncIdObject, isDisabled, asyncState);
return asyncContext;
}
return recordNextAsyncContext();
}
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, args);
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);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class AsyncContextSpanEventEndPointInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final AsyncContext asyncContext = getAsyncContext(target, args);
if (asyncContext == null) {
logger.debug("Not found asynchronous invocation metadata");
return;
}
if (isDebug) {
logger.debug("Asynchronous invocation. asyncContext={}", asyncContext);
}
final Trace trace = asyncContext.currentAsyncTraceObject();
if (trace == null) {
return;
}
if (isDebug) {
logger.debug("Asynchronous invocation. asyncTraceId={}, trace={}", asyncContext, trace);
}
// leave scope.
if (!leaveAsyncTraceScope(trace)) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to leave scope of async trace {}.", trace);
}
// delete unstable trace.
deleteAsyncTrace(trace);
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
doInAfterTrace(recorder, target, args, result, throwable);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
if (isAsyncTraceDestination(trace)) {
if (isDebug) {
logger.debug("Arrived at async trace destination. asyncTraceId={}", asyncContext);
}
deleteAsyncTrace(trace);
}
finishAsyncState(asyncContext);
}
}
use of com.navercorp.pinpoint.bootstrap.context.AsyncContext in project pinpoint by naver.
the class AsyncContextSpanEventSimpleAroundInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final AsyncContext asyncContext = getAsyncContext(target, args, result, throwable);
if (asyncContext == null) {
logger.debug("AsyncContext not found");
return;
}
final Trace trace = asyncContext.currentAsyncTraceObject();
if (trace == null) {
return;
}
// leave scope.
if (!leaveAsyncTraceScope(trace)) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to leave scope of async trace {}.", trace);
}
// delete unstable trace.
deleteAsyncContext(trace, asyncContext);
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
doInAfterTrace(recorder, target, args, result, throwable);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
} finally {
trace.traceBlockEnd();
if (isAsyncTraceDestination(trace)) {
deleteAsyncContext(trace, asyncContext);
}
}
}
Aggregations