This commit is contained in:
parent
416540754c
commit
44a5fb2e6d
1 changed files with 25 additions and 7 deletions
|
|
@ -248,7 +248,8 @@ public class SignalRestService {
|
|||
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
||||
|
||||
ResponseEntity<String> response = restTemplate.exchange(
|
||||
ResponseEntity<String> response = exchangeWithTiming(
|
||||
"onlinereport",
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
requestEntity,
|
||||
|
|
@ -283,12 +284,12 @@ public class SignalRestService {
|
|||
|
||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(headers);
|
||||
|
||||
ResponseEntity<byte[]> response = restTemplate.exchange(
|
||||
ResponseEntity<byte[]> response = exchangeWithTiming(
|
||||
"onlinedownload",
|
||||
url,
|
||||
HttpMethod.GET,
|
||||
requestEntity,
|
||||
byte[].class
|
||||
);
|
||||
byte[].class);
|
||||
Path targetFilePathWithExt = null;
|
||||
if (response.getHeaders().getContentType().equals(MEDIA_TYPE_GZIP)) {
|
||||
Path folder = Path.of(config.getLoadDir(),
|
||||
|
|
@ -333,4 +334,21 @@ public class SignalRestService {
|
|||
return "unknown error";
|
||||
return "%s: %s".formatted(response.getError().getName(), response.getError().getDescription());
|
||||
}
|
||||
|
||||
private <T> ResponseEntity<T> exchangeWithTiming(
|
||||
String name,
|
||||
String url,
|
||||
HttpMethod method,
|
||||
HttpEntity<?> requestEntity,
|
||||
Class<T> responseType
|
||||
) {
|
||||
long start = System.nanoTime();
|
||||
|
||||
try {
|
||||
return restTemplate.exchange(url, method, requestEntity, responseType);
|
||||
} finally {
|
||||
long durationMs = (System.nanoTime() - start) / 1_000_000;
|
||||
log.info("REST [{}] {} {} took {} ms", name, method, url, durationMs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue