0

I am currently migrating from 2.10.x (bom) and when I tried 2.11.3 (bom) I found that org.eclipse.microprofile.metrics.annotation.Gauge no longer exists. This comes from the following jar:-

org.eclipse.microprofile.metrics:microprofile-metrics-api:3.0.1

I feel like I must have missed something in the migration notes but I am unclear what to do about it.

Any help would be much appreciated.

trisport88
  • 33
  • 2
  • `2.11` is quite old, the most recent release is `2.16`, would upgrading be an option? --- Can you share your `pom.xml`? Are yo using smallrye-metrics or micrometer? – Turing85 Jan 19 '23 at 22:26
  • The [relevant part of the guide](https://quarkus.io/guides/micrometer#support-for-the-microprofile-metrics-api) might be of interest. Looks like mp-metrics must be included explicitly, and `micrometer` will add an adaptive layer to support it. – Turing85 Jan 19 '23 at 22:30
  • I will be migrating to 2.16 but wanted to migrate step by step and fix what breaks. We are using gradle. When I look at the dependency tree for io.quarkus:quarkus-universe-bom:2.11.3.Final it does not include the above lib but 2.10.3 does. – trisport88 Jan 19 '23 at 22:33
  • Thanks @Turing85, I will try explicitly added the dependency. Strange that it was removed and not mentioned in the migration docs. – trisport88 Jan 19 '23 at 22:39
  • Let me know if it solves the problem. If it does, I'll post an answer. – Turing85 Jan 19 '23 at 22:46
  • It compiled but there was a runtime problem: Multiple producers of item class io.quarkus.deployment.metrics.MetricsCapabilityBuildItem. I think because we have both io.quarkus:quarkus-micrometer-registry-prometheus and io.quarkus:quarkus-smallrye-metrics. I will poke around some more. – trisport88 Jan 19 '23 at 22:51
  • [Smallrye-metrics is deprecated; micrometer is recommended](https://quarkus.io/guides/smallrye-metrics). And yes: we cannot have both smallrye-metrics and micrometer on the classpath. – Turing85 Jan 19 '23 at 22:53
  • 1
    https://quarkus.io/guides/micrometer#support-for-the-microprofile-metrics-api (adding implementation("org.eclipse.microprofile.metrics:microprofile-metrics-api") seems to do the trick). – trisport88 Jan 19 '23 at 23:06

1 Answers1

0

It seems that the transitive dependency to microprofile-metrics-api was removed from quarkus version 2.11.x onwards. Thus, if we want to use it, we have to add it.

For gradle, we add the following line to our build.gradle:

implementation("org.eclipse.microprofile.metrics:microprofile-metrics-api")

For maven, we add the following line to our pom.xml:

<dependency>
    <groupId>org.eclipse.microprofile.metrics</groupId>
    <artifactId>microprofile-metrics-api</artifactId>
</dependency>

(The snippets for the build.gradle and pom.xml were taken from the official quarkus guide)

Turing85
  • 18,217
  • 7
  • 33
  • 58