Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement /actuator/info endpoint #28

Open
nitomartinez opened this issue Jan 6, 2020 · 0 comments
Open

Implement /actuator/info endpoint #28

nitomartinez opened this issue Jan 6, 2020 · 0 comments

Comments

@nitomartinez
Copy link

nitomartinez commented Jan 6, 2020

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);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant