@Override public void after(Object target, Object[] args, Object result, Throwable throwable) { if (isDebug) { logger.afterInterceptor(target, args); } final Trace trace = traceContext.currentRawTraceObject(); if (trace == null) { return; } // check user include trace. if (!isUserIncludeTrace(trace)) { return; } // leave scope(default & disable trace). if (!leaveUserIncludeTraceScope(trace)) { logger.warn( "Failed to leave scope of user include trace. trace={}, sampled={}", trace, trace.canSampled()); // delete unstable trace. deleteUserIncludeTrace(trace); return; } // check sampled. if (!trace.canSampled()) { if (isUserIncludeTraceDestination(trace)) { deleteUserIncludeTrace(trace); } return; } try { final SpanEventRecorder recorder = trace.currentSpanEventRecorder(); recorder.recordApi(descriptor); recorder.recordServiceType(ServiceType.INTERNAL_METHOD); recorder.recordException(throwable); } finally { trace.traceBlockEnd(); if (isUserIncludeTraceDestination(trace)) { deleteUserIncludeTrace(trace); } } }
@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(); } }