use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class HttpServletRequestImplInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, "", descriptor.getMethodName(), "", args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (validate(target, result, throwable)) {
((AsyncAccessor) target)._$PINPOINT$_setAsync(Boolean.TRUE);
// make asynchronous trace-id
final AsyncTraceId asyncTraceId = trace.getAsyncTraceId();
recorder.recordNextAsyncId(asyncTraceId.getAsyncId());
// result is BasicFuture type check validate()
((AsyncTraceIdAccessor) result)._$PINPOINT$_setAsyncTraceId(asyncTraceId);
if (isDebug) {
logger.debug("Set asyncTraceId metadata {}", asyncTraceId);
}
}
recorder.recordServiceType(ResinConstants.RESIN_METHOD);
recorder.recordApi(descriptor);
recorder.recordException(throwable);
} catch (Throwable t) {
logger.warn("Failed to AFTER process. {}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class ServletInvocationInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
try {
final Trace trace = createTrace(target, args);
if (trace == null) {
return;
}
// TODO STATDISABLE this logic was added to disable statistics tracing
if (!trace.canSampled()) {
return;
}
// ------------------------------------------------------
SpanEventRecorder recorder = trace.traceBlockBegin();
recorder.recordServiceType(ResinConstants.RESIN_METHOD);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class ServletInvocationInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args, result, throwable);
}
final Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
return;
}
// TODO STATDISABLE this logic was added to disable statistics tracing
if (!trace.canSampled()) {
traceContext.removeTraceObject();
return;
}
// ------------------------------------------------------
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
if (this.isTraceRequestParam) {
final HttpServletRequest request = (HttpServletRequest) args[0];
if (!excludeProfileMethodFilter.filter(request.getMethod())) {
final String parameters = getRequestParameter(request, 64, 512);
if (parameters != null && parameters.length() > 0) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}
}
recordRequest(trace, request, throwable);
}
final HttpServletResponse response = (HttpServletResponse) args[1];
if (throwable != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, 500);
recorder.recordException(throwable);
} else {
if (isResinVersion4(target)) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, response.getStatus());
}
}
recorder.recordApi(methodDescriptor);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", th.getMessage(), th);
}
} finally {
traceContext.removeTraceObject();
deleteTrace(trace, target, args, result, throwable);
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class PreparedStatementExecuteQueryInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
SpanEventRecorder recorder = trace.traceBlockBegin();
try {
DatabaseInfo databaseInfo = (target instanceof DatabaseInfoAccessor) ? ((DatabaseInfoAccessor) target)._$PINPOINT$_getDatabaseInfo() : null;
if (databaseInfo == null) {
databaseInfo = UnKnownDatabaseInfo.INSTANCE;
}
recorder.recordServiceType(databaseInfo.getExecuteQueryType());
recorder.recordEndPoint(databaseInfo.getMultipleHost());
recorder.recordDestinationId(databaseInfo.getDatabaseId());
ParsingResult parsingResult = null;
if (target instanceof ParsingResultAccessor) {
parsingResult = ((ParsingResultAccessor) target)._$PINPOINT$_getParsingResult();
}
Map<Integer, String> bindValue = null;
if (target instanceof BindValueAccessor) {
bindValue = ((BindValueAccessor) target)._$PINPOINT$_getBindValue();
}
if (bindValue != null) {
String bindString = toBindVariable(bindValue);
recorder.recordSqlParsingResult(parsingResult, bindString);
} else {
recorder.recordSqlParsingResult(parsingResult);
}
recorder.recordApi(descriptor);
// trace.recordApi(apiId);
// Need to change where to invoke clean().
// There is cleanParameters method but it's not necessary to intercept that method.
// iBatis intentionally does not invoke it in most cases.
clean(target);
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(e.getMessage(), e);
}
}
}
use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class SpanAsyncEventSimpleAroundInterceptor method before.
@Override
public void before(Object target, Object[] args) {
if (isDebug) {
logger.beforeInterceptor(target, args);
}
final AsyncTraceId asyncTraceId = getAsyncTraceId(target);
if (asyncTraceId == null) {
logger.debug("Not found asynchronous invocation metadata");
return;
}
Trace trace = traceContext.currentRawTraceObject();
if (trace == null) {
// create async trace;
trace = createAsyncTrace(asyncTraceId);
if (trace == null) {
return;
}
} else {
// check sampled.
if (!trace.canSampled()) {
// sckip.
return;
}
}
// entry scope.
entryAsyncTraceScope(trace);
try {
// trace event for default & async.
final SpanEventRecorder recorder = trace.traceBlockBegin();
doInBeforeTrace(recorder, asyncTraceId, target, args);
} catch (Throwable th) {
if (logger.isWarnEnabled()) {
logger.warn("BEFORE. Caused:{}", th.getMessage(), th);
}
}
}
Aggregations