Fix ConsulHealthIndicator to stop reading internal config values from v1/agent/self and switch to a more stable API (#370)

This commit is contained in:
Preetha
2017-11-16 13:42:19 -06:00
committed by Spencer Gibb
parent e662c6b0ec
commit a8ef24246f

View File

@@ -41,19 +41,13 @@ public class ConsulHealthIndicator extends AbstractHealthIndicator {
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
try {
Response<Self> self = consul.getAgentSelf();
Config config = self.getValue().getConfig();
try {
Response<String> leaderStatus = consul.getStatusLeader();
Response<Map<String, List<String>>> services = consul
.getCatalogServices(QueryParams.DEFAULT);
builder.up()
.withDetail("services", services.getValue())
.withDetail("advertiseAddress", config.getAdvertiseAddress())
.withDetail("datacenter", config.getDatacenter())
.withDetail("domain", config.getDomain())
.withDetail("nodeName", config.getNodeName())
.withDetail("bindAddress", config.getBindAddress())
.withDetail("clientAddress", config.getClientAddress());
.withDetail("leader", leaderStatus.getValue())
.withDetail("services", services.getValue());
}
catch (Exception e) {
builder.down(e);