use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class BasicMethodInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
final SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(serviceType);
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class BasicMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(descriptor);
recorder.recordException(throwable);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class SpanAsyncEventSimpleAroundInterceptor method createAsyncTrace.
private Trace createAsyncTrace(AsyncTraceId asyncTraceId) {
final Trace trace = traceContext.continueAsyncTraceObject(asyncTraceId, asyncTraceId.getAsyncId(), asyncTraceId.getSpanStartTime());
if (trace == null) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to continue async trace. 'result is null'");
}
return null;
}
if (isDebug) {
logger.debug("Continue async trace {}, id={}", trace, asyncTraceId);
}
// add async scope.
TraceScope oldScope = trace.addScope(ASYNC_TRACE_SCOPE);
if (oldScope != null) {
if (logger.isWarnEnabled()) {
logger.warn("Duplicated async trace scope={}.", oldScope.getName());
}
// delete corrupted trace.
deleteAsyncTrace(trace);
return null;
}
// first block.
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordServiceType(ServiceType.ASYNC);
recorder.recordApi(asyncMethodDescriptor);
return trace;
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class SpanAsyncEventSimpleAroundInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final AsyncTraceId asyncTraceId = getAsyncTraceId(target);
if (asyncTraceId == null) {
logger.debug("Not found asynchronous invocation metadata");
return;
}
Trace trace = traceContext.currentTraceObject();
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.
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)) {
deleteAsyncTrace(trace);
}
finishAsyncState(asyncTraceId);
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class SpanEventSimpleAroundInterceptorForPlugin method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logBeforeInterceptor(target, args);
}
prepareBeforeTrace(target, args);
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.traceBlockBegin();
doInBeforeTrace(recorder, target, args);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations