-
Notifications
You must be signed in to change notification settings - Fork 2.8k
@Gauge of SmallRye Metrics not working in API Rest Beans - not managed by CDI #47037
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
Comments
/cc @Ladicek (arc,smallrye), @ebullient (metrics), @jmartisk (metrics,smallrye), @manovotn (arc), @mkouba (arc), @phillip-kruger (smallrye), @radcortez (smallrye) |
Could you please paste the full stack trace? The snippet doesn't even show who is trying to obtain an instance of the bean while the request context is not active. |
Mixing a Gauge into a REST API is wrong and you should split out the gauge into a separate application-scoped bean. A gauge also can only return a numeric value ( |
Perfect, I understand. Now, the code loses readability by separating the metrics into different layers, resources (Timed, Metered) and beans/services (Gauge), for example. How to do it? |
Note that there are already request-bound metrics for http requests coming directly from the micrometer extension http-*, as noted in the docs: https://quarkus.io/guides/telemetry-micrometer#automatically-generated-metrics What you're adding here is redundant and unnecessary as well as unsupported (as I explained in your other issue/discussion and @jmartisk has reiterated). I think your understanding of how to provide a gauge is also not quite right. You're measuring something on a clientService. Tying that gauge to a rest method doesn't make a lot of sense: you've got the concern in the wrong place. To Jan's point about using another bean as the gauge: If you want that rest method to be able to observe the current value of that gauge, there are a few different ways to look up the associated/generated gauge bean to return what the most current observed value is. |
Describe the bug
``
public final class AuthenticationResource {
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
19
Output of
java -version
17
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: