Skip to content

[kafka][metrics] Unable to Disable KafkaBinderMetrics Bean in MultiBinder Scenario #3114

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

Open
ferblaca opened this issue May 16, 2025 · 0 comments

Comments

@ferblaca
Copy link
Contributor

ferblaca commented May 16, 2025

Describe the issue
I would like to be able to disable the KafkaBinderMetrics bean, which is responsible for periodically monitoring and calculating the spring.cloud.stream.binder.kafka.offset metric.

Although this bean is annotated with @ConditionalOnMissingBean(KafkaBinderMetrics.class), in a multi-binder scenario it is not possible to disable it, even when creating a specific configuration for the binder using the spring.main.resources property, as shown in this example application.

I believe this happens because, in a multi-binder scenario, the configurations specified in the spring.main.resources property are always loaded after the KafkaBinderConfiguration is initialized.

The motivation for disabling the LAG metrics is that native Kafka metrics already reflect the LAG, and the KafkaBinderMetrics bean creates a scheduler that runs periodically to perform calculations—even when filtering those metrics using an Observability API filter—which consumes system resources.

To Reproduce
Steps to reproduce the behavior:

  1. Start the application located in this repository
  2. Check that the spring_cloud_stream_binder_kafka_offset metrics still appear in the Prometheus endpoint

Version of the framework

  • Spring Boot: 3.4.5
  • Spring Cloud: 2024.01

Expected behavior
The KafkaBinderMetrics bean should not be created in a multi-binder scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant