[En] How to activate microprofile metrics in OpenLiberty

In Jakarta EE Microprofile you can use Metrics easily.  No need for Hystrix project.  The simple code in order to show how to use Metrics in the codebase

public List<Ping> getAllPings() { 
   return pingBean.getAllPings() ;

@Counted(monotonic = true)
public Ping save(Ping ping) {
   return pingBean.save(ping);

Project’s pom.xml could be like this :



In OpenLiberty’s server.xml file, default server.xml can be found under $OPENLIBETY_HOME/usr/servers/defaultServer/

If you add this two lines into server.xml


then you could see the metrics in http://localhost:9080/metrics url

Sample project could be found at https://github.com/altuga/airhacks

No Comments

Post a Comment