0

Microprofile allows you to expose metrics for your application, but common logic is placed in a separate repository which is added as a dependency to the POM.

How can I get the metrics for this common library which is included in all of our microservices?

The metrics for the microservice itself work and show up at the endpoint. I verified the code from the common library is actually called. It has the same annotation as used in the microservice (@Timed). It has the same dependency on microprofile metrics in the POM.

For the microservice, the metrics are enabled in the server.xml like so: <feature>mpMetrics-3.0</feature> But the common library does not have a server.xml since it is only ever used as a dependency and never deployed separately.

Edit:

I'm thinking it has to do with creating the object in a Produces method. This does work however for my own custom interceptor, but it doesn't seem to pick up the @Timed from microprofile metrics.

@Produces
public RedisStore produceRedisStore(InterceptionFactory<RedisStore> factory) {
    return factory.createInterceptedInstance(
            new RedisStore(...));
}

When making the RedisStore @ApplicationScoped, the metrics do show up. This verifies that it most likely has something to do with the @Produces method.

Vinagy
  • 133
  • 2
  • 11

0 Answers0