@Override public void after(Object target, Object result, Throwable throwable, Object[] args) { if (isDebug) { logger.afterInterceptor( target, methodDescriptor.getClassName(), methodDescriptor.getMethodName(), "", args, result, throwable); } final Trace trace = traceContext.currentTraceObject(); if (trace == null) { return; } InterceptorGroupInvocation invocation = interceptorGroup.getCurrentInvocation(); if (invocation != null && invocation.getAttachment() != null) { HttpCallContext callContext = (HttpCallContext) invocation.getAttachment(); if (methodDescriptor.getMethodName().equals("doSendRequest")) { callContext.setWriteEndTime(System.currentTimeMillis()); callContext.setWriteFail(throwable != null); } else { callContext.setReadEndTime(System.currentTimeMillis()); callContext.setReadFail(throwable != null); } logger.debug("Set call context {}", callContext); } }
private String getMethodUri(Object target) { String methodUri = UNKNOWN_METHOD_URI; InterceptorGroupInvocation currentTransaction = this.group.getCurrentInvocation(); Object attachment = currentTransaction.getAttachment(); if (attachment instanceof ThriftClientCallContext && target instanceof TBaseProcessor) { ThriftClientCallContext clientCallContext = (ThriftClientCallContext) attachment; String methodName = clientCallContext.getMethodName(); methodUri = ThriftUtils.getProcessorNameAsUri((TBaseProcessor<?>) target); StringBuilder sb = new StringBuilder(methodUri); if (!methodUri.endsWith("/")) { sb.append("/"); } sb.append(methodName); methodUri = sb.toString(); } return methodUri; }
@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; } if (!validate(target)) { return; } try { SpanEventRecorder recorder = trace.currentSpanEventRecorder(); recorder.recordApi(methodDescriptor); recorder.recordException(throwable); Request request = ((UserRequestGetter) target)._$PINPOINT$_getUserRequest(); if (request != null) { recorder.recordAttribute(AnnotationKey.HTTP_URL, request.httpUrl().toString()); recorder.recordDestinationId(request.httpUrl().host() + ":" + request.httpUrl().port()); recordRequest(trace, request, throwable); } // clear attachment. InterceptorGroupInvocation invocation = interceptorGroup.getCurrentInvocation(); if (invocation != null && invocation.getAttachment() != null) { invocation.removeAttachment(); } } finally { trace.traceBlockEnd(); } }