use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class TransactionIdStartedInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
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);
}
traceContext.removeTraceObject();
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
LogMarkerToken logMarkerToken = (LogMarkerToken) args[2];
String message = ((Function0) args[3]).apply().toString();
recorder.recordApi(new LogMarkerMethodDescriptor(logMarkerToken));
if (logMarkerToken.component().equals("database")) {
recorder.recordServiceType(OpenwhiskConstants.COUCHDB_EXECUTE_QUERY);
recorder.recordDestinationId("COUCHDB");
recorder.recordAttribute(OpenwhiskConstants.MARKER_MESSAGE, message);
} else {
recorder.recordServiceType(OpenwhiskConstants.OPENWHISK_INTERNAL);
if (isLoggingMessage && message.length() > 0) {
recorder.recordAttribute(OpenwhiskConstants.MARKER_MESSAGE, message);
}
}
if (result instanceof AsyncContextAccessor && result instanceof PinpointTraceAccessor) {
((AsyncContextAccessor) (result))._$PINPOINT$_setAsyncContext(asyncContext);
((PinpointTraceAccessor) (result))._$PINPOINT$_setPinpointTrace(trace);
}
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER error. Caused:{}", th.getMessage(), th);
}
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HbaseClientConstructorInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
AsyncContext asyncContext = (AsyncContext) scope.getCurrentInvocation().getAttachment();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HttpRequestExecuteAsyncMethodInnerClassConstructorInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
if (!validate(target, args)) {
return;
}
final InterceptorScopeInvocation transaction = interceptorScope.getCurrentInvocation();
final AsyncContext asyncContext = getAsyncContext(transaction);
if (asyncContext != null) {
// type check validate();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
// clear.
transaction.removeAttachment();
}
} 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 AbstractHttpServerHandleInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
if (traceContext.currentRawTraceObject() != null) {
if (isDisconnecting(args)) {
final AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
if (asyncContext != null) {
if (asyncContext instanceof AsyncStateSupport) {
final AsyncStateSupport asyncStateSupport = (AsyncStateSupport) asyncContext;
AsyncState asyncState = asyncStateSupport.getAsyncState();
asyncState.finish();
if (isDebug) {
logger.debug("Finished asyncState. asyncTraceId={}", asyncContext);
}
}
}
}
// duplicate trace.
return;
}
try {
if (Boolean.FALSE == isReceived(args)) {
// invalid args
return;
}
final HttpServerRequest request = (HttpServerRequest) args[0];
final HttpServerResponse response = (HttpServerResponse) args[0];
this.servletRequestListener.initialized(request, ReactorNettyConstants.REACTOR_NETTY_INTERNAL, this.methodDescriptor);
// must after request listener due to trace block begin
this.servletResponseListener.initialized(response, ReactorNettyConstants.REACTOR_NETTY_INTERNAL, this.methodDescriptor);
// Set end-point
final Trace trace = this.traceContext.currentTraceObject();
if (trace == null) {
return;
}
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (recorder != null) {
// make asynchronous trace-id
final boolean asyncStateSupport = enableAsyncEndPoint;
final AsyncContext asyncContext = recorder.recordNextAsyncContext(asyncStateSupport);
((AsyncContextAccessor) args[0])._$PINPOINT$_setAsyncContext(asyncContext);
if (isDebug) {
if (enableAsyncEndPoint) {
logger.debug("Set closeable-AsyncContext {}", asyncContext);
} else {
logger.debug("Set AsyncContext {}", asyncContext);
}
}
}
} catch (Throwable t) {
if (isInfo) {
logger.info("Failed to servlet request event handle.", t);
}
}
}
use of com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor in project pinpoint by naver.
the class HttpClientHandlerConstructorInterceptor 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 (throwable == null && target instanceof AsyncContextAccessor) {
final AsyncContext asyncContext = recorder.recordNextAsyncContext();
((AsyncContextAccessor) target)._$PINPOINT$_setAsyncContext(asyncContext);
}
}
Aggregations