Skip to content

Implement /actuator/info endpoint #28

Description

@nitomartinez

I was greatly surprised to see that /actuator/health is implemented ;-)

$ curl http://127.0.0.1:8080/actuator/health
{"status":"UP",
  "components":{   
     "diskSpace":{"status":"UP","details" {"total":73867264000,"free":4643659776,"threshold":10485760}},
     "ping":{"status":"UP"},
     "web3j":{"status":"UP","details":{"clientVersion":"Autonity/v0.3.0-de53f1f3/linux-amd64/go1.11.13","netVersion":"1","blockNumber":79902,"protocolVersion":"0x3f","netPeerCount":4}}
}}

Would it make sense to implement also the info endpoint? (in fact I would probably move most of the output to the info endpoint instead of the health endpoint, but it is just an opinion)

https://github.com/web3j/web3j-spring-boot-starter/blob/master/src/main/java/org/web3j/spring/actuate/Web3jHealthIndicator.java

Just in case anyone bumps into this issue, my workaround implementing the info actuator so far is:

@Component
public class Web3jInfoContributor implements InfoContributor {
    @Autowired
    HealthContributorRegistry registry;

    @Override
    public void contribute(Builder builder) {
        Map<String, Object> web3jhealthinfo = registry.stream().
                // Work only on the web3j HealthContributor
                filter(x -> (x.getName().equals("web3j") && x.getContributor() instanceof HealthIndicator)).
                // Get the HealthIndicator from the HealthContributor
                map(x -> ((HealthIndicator) x.getContributor()).
                // Get Health->Details->Map<String,Object>
                        health().getDetails())
                .findFirst().orElse(null);

        builder.withDetail("web3j", web3jhealthinfo);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions