use of com.navercorp.pinpoint.plugin.openwhisk.accessor.PinpointTraceAccessor in project pinpoint by naver.
the class TransactionIdFailedInterceptor method before.
@Override
public void before(Object target, Object[] args) {
AsyncContextAccessor accessor = ArrayArgumentUtils.getArgument(args, 2, AsyncContextAccessor.class);
AsyncContext asyncContext = accessor._$PINPOINT$_getAsyncContext();
final Trace trace = ((PinpointTraceAccessor) accessor)._$PINPOINT$_getPinpointTrace();
if (asyncContext == null || trace == null) {
return;
}
// set error message
String message = ((Function0) args[3]).apply().toString();
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordException(new Throwable(message));
logger.debug("Record failed message : {}", message);
// close trace block and context
trace.traceBlockEnd();
trace.close();
asyncContext.close();
}
use of com.navercorp.pinpoint.plugin.openwhisk.accessor.PinpointTraceAccessor 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);
}
}
}
Aggregations