use of com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder in project pinpoint by naver.
the class TAsyncClientManagerCallInterceptor 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 = this.traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordApi(this.descriptor);
recorder.recordException(throwable);
} catch (Throwable t) {
logger.warn("AFTER error. Caused:{}", t.getMessage(), t);
} finally {
trace.traceBlockEnd();
}
}
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 HttpRequestExecutorExecuteMethodInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (isDebug) {
logger.afterInterceptor(target, args);
}
final Trace trace = traceContext.currentTraceObject();
if (trace == null) {
return;
}
try {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
final HttpRequest httpRequest = getHttpRequest(args);
if (httpRequest != null) {
// Accessing httpRequest here not BEFORE() because it can cause side effect.
if (httpRequest.getRequestLine() != null) {
final String httpUrl = InterceptorUtils.getHttpUrl(httpRequest.getRequestLine().getUri(), param);
recorder.recordAttribute(AnnotationKey.HTTP_URL, httpUrl);
}
final NameIntValuePair<String> host = getHost();
if (host != null) {
final String endpoint = getEndpoint(host.getName(), host.getValue());
recorder.recordDestinationId(endpoint);
}
recordHttpRequest(trace, httpRequest, throwable);
}
if (statusCode) {
final Integer statusCodeValue = getStatusCode(result);
if (statusCodeValue != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, statusCodeValue);
}
}
recorder.recordApi(methodDescriptor);
recorder.recordException(throwable);
final InterceptorScopeInvocation invocation = interceptorScope.getCurrentInvocation();
if (invocation != null && invocation.getAttachment() != null && invocation.getAttachment() instanceof HttpCallContext) {
final HttpCallContext callContext = (HttpCallContext) invocation.getAttachment();
logger.debug("Check call context {}", callContext);
if (io) {
final StringBuilder sb = new StringBuilder();
sb.append("write=").append(callContext.getWriteElapsedTime());
if (callContext.isWriteFail()) {
sb.append("(fail)");
}
sb.append(", read=").append(callContext.getReadElapsedTime());
if (callContext.isReadFail()) {
sb.append("(fail)");
}
recorder.recordAttribute(AnnotationKey.HTTP_IO, sb.toString());
}
// clear
invocation.removeAttachment();
}
} finally {
trace.traceBlockEnd();
}
}
Aggregations