Skip to content

Commit 3eb9790

Browse files
authored
Improve logging for optional services health checks (#852)
1 parent 67d7335 commit 3eb9790

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/org/gridsuite/study/server/service/RemoteServicesInspector.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public List<ServiceStatusInfos> getOptionalServices() {
8484
// parallel health status check for all services marked as "optional: true" in application.yaml
8585
List<CompletableFuture<ServiceStatusInfos>> results = remoteServicesProperties.getServices().stream()
8686
.filter(RemoteServicesProperties.Service::isOptional)
87-
.map(service -> asyncSelf.isServerUp(service).thenApply(isUp -> ServiceStatusInfos.builder()
87+
.map(service -> asyncSelf.isOptionalServiceUp(service).thenApply(isUp -> ServiceStatusInfos.builder()
8888
.name(service.getName())
8989
.status(Boolean.TRUE.equals(isUp) ? ServiceStatus.UP : ServiceStatus.DOWN)
9090
.build()))
@@ -93,20 +93,28 @@ public List<ServiceStatusInfos> getOptionalServices() {
9393
return results.stream().map(CompletableFuture::join).toList();
9494
}
9595

96+
/**
97+
* Check if an optional service is up and running.
98+
* This method is specifically designed for optional services and uses debug-level logging
99+
* to avoid polluting stdout with expected failures.
100+
*
101+
* @param service the optional service to check
102+
* @return CompletableFuture<Boolean> true if service is UP, false otherwise
103+
*/
96104
@Async
97-
public CompletableFuture<Boolean> isServerUp(RemoteServicesProperties.Service service) {
105+
public CompletableFuture<Boolean> isOptionalServiceUp(RemoteServicesProperties.Service service) {
98106
try {
99107
final String result = restTemplate.getForObject(service.getBaseUri() + "/actuator/health", String.class);
100108
final JsonNode node = objectMapper.readTree(result).path(ACTUATOR_HEALTH_STATUS_JSON_FIELD);
101109
if (node.isMissingNode()) {
102-
LOGGER.error("Cannot find {} json node while testing '{}'", ACTUATOR_HEALTH_STATUS_JSON_FIELD, service.getName());
110+
LOGGER.debug("Cannot find {} json node while testing '{}'", ACTUATOR_HEALTH_STATUS_JSON_FIELD, service.getName());
103111
} else {
104112
return CompletableFuture.completedFuture("UP".equalsIgnoreCase(node.asText()));
105113
}
106114
} catch (RestClientException e) {
107-
LOGGER.error("Network error while testing " + service.getName(), e);
115+
LOGGER.debug("Network error while testing {}", service.getName(), e);
108116
} catch (JsonProcessingException e) {
109-
LOGGER.error("Json parsing error while testing " + service.getName(), e);
117+
LOGGER.debug("Json parsing error while testing {}", service.getName(), e);
110118
}
111119
return CompletableFuture.completedFuture(false);
112120
}

0 commit comments

Comments
 (0)