org.springframework.http.client.AbstractClientHttpResponse Java Examples

The following examples show how to use org.springframework.http.client.AbstractClientHttpResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListenableFutureInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@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);
        }
    }
}