-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Missing RabbitMQ metrics if bean is defined as a ConnectionFactory #25138
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
@Huo12345 I don't see anything in your application that configures the RabbitMQ connection on Cloud Foundry, so it appears that the A better approach is to include the Java CFEnv library in your application as shown in the CFEnv documentation and disable buildpack auto-reconfiguration when pushing the app to CF. There is no additional code to write, just adding the CFEnv dependency is sufficient. This will result in Boot auto-configuration creating the Can you try this approach and see if it addresses your issue? |
@scottfrederick I can confirm that using the Java CFEnv library fixes the issue mentioned above. So my issue is fixed, thanks. |
Arguably this is a bug in the CloudFoundry code that defines the bean as a The metrics auto-configuration requires an |
@wilkinsona Which documentation? And, to what? Any boot examples generally rely on the auto-configured beans and don't define any. Or, do you mean change all the examples that do define a connection factory The metrics BPP checks the bean type anyway, so making it conditional on the interface wouldn't break anything. |
Sorry for not being clear, Gary. I was referring to the documentation that @Huo12345 linked to above.
Yeah, indeed, it won't break anything. It may end up being defined unnecessarily but I think that's unlikely and it certainly wouldn't be the end of the world if it was. |
Sorry; I missed that comment.
Yes, and as you said, it is [extremely] unlikely it wouldn't be an ACF, except perhaps in tests where it might be a mock CF. |
There is an issue to address the usage of Spring Cloud Connectors in the Java buildpack, and the Java CFEnv documentation covers this use case in the interim. I'll close this issue. |
We've decided to tweak the condition so the post-processor will be in place if the bean is defined as a |
Expected behaviour
When deploying an application with a RabbitMQ connection and prometheus metrics enabled to cloud foundy, the prometheus endpoint should expose metrics for RabbitMQ as documented in Spring Boot Reference Documentation similar to when run locally.
Observed behaviour
When deployed to cloud foundry, no RabbitMQ metrics are exposed on the prometheus endpoint.
Steps to reproduce
local
and check prometheus endpoint for entries withrabbit
-> Should have multiplerabbit
-> Should have none.4.1 If there is no cloud foundry instance available for testing, you can run the app with profile
ab
to see the metrics andif
to not see them. More details in section Probable Cause.Probable Cause
When investigating this issue I found that
RabbitMetricsAutoConfiguration
class has the condition@ConditionalOnBean({ AbstractConnectionFactory.class, MeterRegistry.class })
attached. From code snippets in the documentation I assume that cloud foundry exposes the connection asConnectionFactory
, an interface implemented byAbstractConnectionFactory
. To test this theory I manually configured aCachingConnectionFactory
and exposed it in a bean of typeConnectionFactory
andAbstractConnectionFactory
(see class RabbitConfig in attached code, profilesab
forAbstractConnectionFactory
andif
forConnectionFactory
). When exposing it asConnectionFactory
no metrics were available, but when usingAbstractConnectionFactory
the metrics showed up in the prometheus endpoint. Is it possible to change the conditional onRabbitMetricsAutoConfiguration
to@ConditionalOnBean({ ConnectionFactory.class, MeterRegistry.class })
to fix this issue?The text was updated successfully, but these errors were encountered: