use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class ChannelPromiseAddListenerInterceptor method doInAfterTrace.
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
if (isAsynchronousInvocation(target, args, result, throwable)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) result)._$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 MongoRSessionInterceptor 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 ChannelPipelineWriteInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (!validate(args)) {
return;
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(NettyConstants.SERVICE_TYPE);
// Inner handler can run before after() method.
// If create AsyncContext in after() method, then there is a possibility that AsyncContext will be saved later than execution
// The write method returns an exception in the Future, so you do not needs to worry about to handle throwable field.
Object request = ArrayUtils.get(args, 0);
if (isAsynchronousInvocation(request)) {
// set asynchronous trace
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) request)._$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 DispatcherEnqueueMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
AsyncContextAccessor accessor = getAsyncContextAccessor(args);
if (accessor == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(methodDescriptor);
recorder.recordServiceType(OkHttpConstants.OK_HTTP_CLIENT_INTERNAL);
recorder.recordException(throwable);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class ServerConnectionHandleRequestInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (traceContext.currentRawTraceObject() != null) {
// duplicate trace.
return;
}
try {
if (!validate(args)) {
// invalid args.
return;
}
final HttpServerRequest request = (HttpServerRequest) args[0];
final HttpServerResponse response = request.response();
if (!(response instanceof AsyncContextAccessor)) {
if (isDebug) {
logger.debug("Invalid response. Need metadata accessor({}).", AsyncContextAccessor.class.getName());
}
return;
}
// create trace for standalone entry point.
final Trace trace = createTrace(request);
if (trace == null) {
return;
}
entryScope(trace);
this.httpHeaderFilter.filter(request);
if (!trace.canSampled()) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(VertxConstants.VERTX_HTTP_SERVER_INTERNAL);
// make asynchronous trace-id
final AsyncContext asyncContext = recorder.recordNextAsyncContext(true);
((AsyncContextAccessor) request)._$PINPOINT$_setAsyncContext(asyncContext);
((AsyncContextAccessor) response)._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
logger.debug("Set closeable-AsyncContext {}", asyncContext);
}
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", t.getMessage(), t);
}
}
}
Aggregations