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

Gauge double registration warning for Kafka consumer metrics #5757

Open
MichaelVilser opened this issue Dec 24, 2024 · 2 comments
Open

Gauge double registration warning for Kafka consumer metrics #5757

MichaelVilser opened this issue Dec 24, 2024 · 2 comments
Labels
bug A general bug instrumentation An issue that is related to instrumenting a component
Milestone

Comments

@MichaelVilser
Copy link

Since #5688 we observe warnings being logged for the default kafka consumer gauge metrics such as 'kafka.consumer.fetch.manager.bytes.consumed.rate' in the form of "This Gauge has been already registered".

Stack trace of when a gauge metric is registered
1stTime_on_startup.txt
2ndTime_after_startup.txt

Looking at this function, it seems like this behavior is actually intended:

@Override
public void bindTo(MeterRegistry registry) {
this.registry = registry;
commonTags = getCommonTags(registry);
prepareToBindMetrics(registry);
checkAndBindMetrics(registry);
scheduler.scheduleAtFixedRate(() -> checkAndBindMetrics(registry), REFRESH_INTERVAL_MILLIS,
REFRESH_INTERVAL_MILLIS, TimeUnit.MILLISECONDS);
}

@oliver-schwab
Copy link

We also see these warnings in our applications, but only in the ones with multiple consumers. Is this also intended?

@jonatan-ivanov
Copy link
Member

jonatan-ivanov commented Jan 24, 2025

Thanks for the issue!
KafkaMetrics needs to re-register Meters since the Kafka client pulls the rug and drops KafkaMetric instances (where it records the data) in some cases. Re-registration is expected but meters should be removed first so the gauge double-registration might indicate a bug.

A proper way to "fix" this would be moving the instrumentation into the Kafka Client itself, so we can instrument this natively and don't need to wrestle with the Kafka Client. Please comment this if you would like to see that happen: https://issues.apache.org/jira/browse/KAFKA-15191

Normally I would say that we have a bug and we don't remove something but based on your first attached file (1stTime_on_startup.txt) it seems this happens at startup so it is also possible that Kafka publishes something twice?

Does any of you have a minimal sample project to reproduce this issue?
Does this happen every time at startup or occasionally?
Does this happen only in case of kafka.consumer.fetch.manager.bytes.consumed.rate or other metrics are also affected?

@jonatan-ivanov jonatan-ivanov added bug A general bug instrumentation An issue that is related to instrumenting a component and removed waiting-for-triage labels Jan 24, 2025
@jonatan-ivanov jonatan-ivanov added this to the 1.13.x milestone Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A general bug instrumentation An issue that is related to instrumenting a component
Projects
None yet
Development

No branches or pull requests

4 participants