I'm trying to use Quarkus MP-Metrics. In a simple API I have a gauge as follows:
@Path("/count")
@GET
@Gauge(unit = MetricUnits.NONE, name = "customersNumberGauge", description = "Number of customers in the inventory")
public int getCustomersNumber()
{
return customerService.getCustomers().size();
}
I also have a couple of unit tests, for example:
@Test
public void testGetCustomerById()
{
get("/customers/1").then().statusCode(200).body("firstName", equalTo("Robert"));
assertMetricValue("fr.simplex_software.aws.lambda.quarkus.CustomerResource.customerByIdCount", 1);
get("/customers/1").then().statusCode(200).body("firstName", equalTo("Robert"));
assertMetricValue("fr.simplex_software.aws.lambda.quarkus.CustomerResource.customerByIdCount", 2);
}
which fails with the exception:
java.lang.IllegalArgumentException: A metric with metricID MetricID{name='fr.simplex_software.aws.lambda.quarkus.CustomerResource.customersNumberGauge', tags=[]} already exists
If I comment out the @Gauge annotation everything works fine. It's worth noting that, by doing that, I'm following exactly the Quarkus quick starts.
Many thanks for any help. Kind regards, Seymour