下面列出了怎么用org.springframework.http.client.AbstractClientHttpResponse的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void doInAfterTrace(SpanEventRecorder recorder, Object target, Object[] args, Object result, Throwable throwable) {
recorder.recordServiceType(RestTemplateConstants.SERVICE_TYPE);
recorder.recordException(throwable);
recorder.recordApi(methodDescriptor);
if (args.length == 1 && args[0] instanceof AbstractClientHttpResponse) {
AbstractClientHttpResponse response = (AbstractClientHttpResponse) args[0];
try {
HttpStatus statusCode = response.getStatusCode();
if (statusCode != null) {
recorder.recordAttribute(AnnotationKey.HTTP_STATUS_CODE, statusCode.value());
}
} catch (IOException ioException) {
logger.warn("Failed to after process. {}", ioException.getMessage(), ioException);
}
}
}