use of com.navercorp.pinpoint.plugin.openwhisk.descriptor.LogMarkerMethodDescriptor 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.plugin.openwhisk.descriptor.LogMarkerMethodDescriptor in project pinpoint by naver.
the class TransactionIdMarkInterceptor method before.
/**
* @param target
* @param args TransactionMetadata, Identify, LogMarkerToken
*/
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
AsyncContext asyncContext = AsyncContextAccessorUtils.getAsyncContext(args, 0);
if (asyncContext == null) {
logger.debug("Not found asynchronous invocation metadata {}", (LogMarkerToken) args[2]);
return;
}
Trace trace = asyncContext.continueAsyncTraceObject();
if (trace == null) {
logger.debug("trace object null");
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(OpenwhiskConstants.OPENWHISK_INTERNAL);
try {
LogMarkerToken logMarkerToken = (LogMarkerToken) args[2];
String message = ((Function0) args[3]).apply().toString();
recorder.recordApi(new LogMarkerMethodDescriptor(logMarkerToken));
if (isLoggingMessage && message.length() > 0) {
recorder.recordAttribute(OpenwhiskConstants.MARKER_MESSAGE, message);
}
} finally {
trace.traceBlockEnd();
trace.close();
asyncContext.close();
}
}
Aggregations