Hello guys,
I am currently using Microprofile along with Payara Micro 5.182.
I just added Metrics to my application, unfortunately, when I try to inject any kind of counter the application just breaks. The error thrown is:
org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408: Unsatisfied dependencies for type Counter with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject @Metric private com.jorge.testapp.api.TestApi.testCounter
at com.jorge.testapp.api.TestApi.testCounter(TestApi.java:0)
-- WELD-001408: Unsatisfied dependencies for type Counter with qualifiers @Default
at injection point [UnbackedAnnotatedField] @Inject @Metric private com.jorge.testapp.api.TestApi.testCounter
at com.jorge.testapp.api.TestApi.testCounter(TestApi.java:0)
Bellow is a sample of my code.
@Inject
@Metric(description = "Test metric")
private Counter testCounter;
@GET
@Path("/v1")
@Timed(name = "getTestTimer", description = "Duration of the getTest call")
public Response getTest() {
Response response;
try {
TestResponse testResponse = testService.doSomething();
response = Response.ok(testResponse).build();
} catch (final TestException e) {
testCounter.inc();
response = Response.status(Status.BAD_REQUEST).build();
}
return response;
}
Does anyone knows why this is happening? It is strange because I've already used Metrics in other projects and everything went according to plan.
It seems that the application metrics are not working at all, since I have @Timed annotations in the code but even though the application runs with them they wont get traced.
Thank you.