Skip to content

Commit 58fd403

Browse files
committed
Merge pull request #4674 from vpavic/improve-health-aggregating
* pr/4674: Add AbstractHealthAggregator.aggregateDetails
2 parents 0650610 + f8090d9 commit 58fd403

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthAggregator.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,20 @@
2626
* aggregating the {@link Status} instances and not deal with contextual details etc.
2727
*
2828
* @author Christian Dupuis
29+
* @author Vedran Pavic
2930
* @since 1.1.0
3031
*/
3132
public abstract class AbstractHealthAggregator implements HealthAggregator {
3233

3334
@Override
3435
public final Health aggregate(Map<String, Health> healths) {
3536
List<Status> statusCandidates = new ArrayList<Status>();
36-
Map<String, Object> details = new LinkedHashMap<String, Object>();
3737
for (Map.Entry<String, Health> entry : healths.entrySet()) {
38-
details.put(entry.getKey(), entry.getValue());
3938
statusCandidates.add(entry.getValue().getStatus());
4039
}
41-
return new Health.Builder(aggregateStatus(statusCandidates), details).build();
40+
Status status = aggregateStatus(statusCandidates);
41+
Map<String, Object> details = aggregateDetails(healths);
42+
return new Health.Builder(status, details).build();
4243
}
4344

4445
/**
@@ -49,4 +50,15 @@ public final Health aggregate(Map<String, Health> healths) {
4950
*/
5051
protected abstract Status aggregateStatus(List<Status> candidates);
5152

53+
/**
54+
* Return the map of 'aggregate' details that should be used from the specified
55+
* healths.
56+
* @param healths the health instances to aggregate
57+
* @return a map of details
58+
* @since 1.3.1
59+
*/
60+
protected Map<String, Object> aggregateDetails(Map<String, Health> healths) {
61+
return new LinkedHashMap<String, Object>(healths);
62+
}
63+
5264
}

0 commit comments

Comments
 (0)