Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micrometer-Microprofile adapter checks annotations in abstract classes #40752

Open
sithmein opened this issue May 21, 2024 · 4 comments
Open
Labels
area/metrics kind/bug Something isn't working

Comments

@sithmein
Copy link

sithmein commented May 21, 2024

Describe the bug

Consider the following abstract class:

public abstract class C {
  @Gauge(name = "foo", unit = MetricUnits.NONE)
  long metric () { return 0; }
}

When the Quarkus application starts, the GaugeAnnotationHandler complains about C uses a @Gauge annotation, but is not @ApplicationScoped, a @singleton, or a REST endpoint. This doesn't make sense because abstract class can never be instantiated and therefore never report any metrics. Only concrete subclasses can and there the check make sense.

Expected behavior

Abstract classes are not checked by the annotation handlers.

Actual behavior

Abstract classes are checked for annotations when it doesn't make sense.

How to Reproduce?

See description.

Output of uname -a or ver

Output of java -version

17.0.11

Quarkus version or git rev

Tested with 3.2.12.Final but the code hasn't change since then

Build tool (ie. output of mvnw --version or gradlew --version)

Maven 3.9.2

Additional information

No response

@sithmein sithmein added the kind/bug Something isn't working label May 21, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented May 21, 2024

/cc @brunobat (micrometer), @ebullient (micrometer)

@geoand
Copy link
Contributor

geoand commented Jun 6, 2024

Does the @Gauge nevertheless work as expected? Forget about that I see it throws an exception.

@geoand
Copy link
Contributor

geoand commented Jun 6, 2024

This check is rather sketchy... Is it really needed @brunobat, @ebullient?

@ebullient
Copy link
Contributor

Just a bug. I was trying to be clear about limitations using the MP Metrics Gauge annotation as it does not work the same in the Micrometer extension as it did with SmallRye Metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/metrics kind/bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

3 participants