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

Add support for KafkaProducerMetrics (similar to KafkaConsumerMetrics) #1095

Closed
OleksiiBondar opened this issue Dec 23, 2018 · 10 comments · Fixed by #1835
Closed

Add support for KafkaProducerMetrics (similar to KafkaConsumerMetrics) #1095

OleksiiBondar opened this issue Dec 23, 2018 · 10 comments · Fixed by #1835
Labels
enhancement A general enhancement
Milestone

Comments

@OleksiiBondar
Copy link
Contributor

OleksiiBondar commented Dec 23, 2018

It would be great to publish Kafka producer metrics which already available through JMX beans.
List of attribute names - https://docs.confluent.io/current/kafka/monitoring.html#producer-metrics

@OleksiiBondar
Copy link
Contributor Author

If no objections, I'd like to work on this improvement.

@jkschneider
Copy link
Contributor

jkschneider commented Dec 31, 2018

Sounds great. Part of the reason we started with consumer metrics is the tagging is difficult to figure out sometimes. It's possible it will be easier for producer side metrics. See the lengthy discussion on #878 for how to infer partition tags. The Kafka docs at least are highly questionable on this feature, so I recommend implementing off of what you see in JMX.

@larsduelfer
Copy link
Contributor

@OleksiiBondar Please check the PR #1166 to fix the consumer metrics. Have you started on this yet? I can support you on this if you want.

@OleksiiBondar
Copy link
Contributor Author

@larsduelfer I've started implementing ProducerMetrics using JMX (similar to Consumer) but as a part of discussion #512 (comment) it was suggested to use more native way (using org.apache.kafka.common.metrics.MetricsReporter interface) which seems to be less error-prone and requires less maintanance in a future. I was able to create prototype and verify briefly consumer metrics, but haven't extend this implementation to support both producer and streams.
I've put this activity on hold for a little bit, should get back to this within a week or so.
You can look into this if interested

@mmaia
Copy link

mmaia commented Apr 14, 2019

I can try helping here with this implementation. But after reading the linked issues and discussions it's still not clear to me which is the final decision. JMX or implementing MetricsReporter directly?
Indeed it seems nice to be possible to bypass JMX but in this case the kafka client will need to be added as an optional dependency of the micrometer core and clients will have to explicitly enable the metrics configuring their kafka clients (consumers, producers or streams). If this is ok then it looks like the best approach indeed.

mmaia added a commit to mmaia/micrometer that referenced this issue May 4, 2019
…ort-for-kafka' into micrometer-metrics#1095-add-support-for-kafka

# Conflicts:
#	micrometer-core/src/main/java/io/micrometer/core/instrument/binder/kafka/KafkaClientMetrics.java
mmaia added a commit to mmaia/micrometer that referenced this issue Jun 3, 2019
…ort-for-kafka' into micrometer-metrics#1095-add-support-for-kafka

# Conflicts:
#	build.gradle
#	gradle/wrapper/gradle-wrapper.properties
#	micrometer-core/src/main/java/io/micrometer/core/instrument/binder/kafka/KafkaClientMetrics.java
@shakuzen shakuzen added the enhancement A general enhancement label Jun 17, 2019
@shakuzen shakuzen modified the milestones: 1.2.0 (non-LTS), 1.3.0 Jun 28, 2019
@shakuzen
Copy link
Member

I can try helping here with this implementation. But after reading the linked issues and discussions it's still not clear to me which is the final decision. JMX or implementing MetricsReporter directly?

I think the MetricsReporter route would be better going forward. #1173 is open with an implementation of this, but we have a couple things to figure out before we can merge it still. Feel free to take a look and help out.

@shakuzen shakuzen modified the milestones: 1.3.0, 1.4.0 Oct 1, 2019
@XiyuanHu
Copy link

XiyuanHu commented Oct 7, 2019

Hi, does it mean that to merge this PR, it requires #1173 to be merged first? Is there any branch already contains the change for this PR but just keeps unmerged? Thanks!

@shakuzen
Copy link
Member

Hi, does it mean that to merge this PR, it requires #1173 to be merged first?

That is the current thinking. At least the approach taken by it is the direction we want to go moving forward.

Is there any branch already contains the change for this PR but just keeps unmerged? Thanks!

No, there isn't any branch with the changes yet.

@OneCricketeer
Copy link

Status?

shakuzen pushed a commit that referenced this issue Mar 10, 2020
Provides a replacement for the `KafkaConsumerMetrics` binder (uses JMX) - `KafkaClientMetrics` and `KafkaStreamsMetrics` binders based off metrics provided by the Kafka client API. This allows all metrics provided by the client to be registered as Micrometer metrics, with the caveat that metrics with the same name but less tags will not be registered. For some metrics, Kafka provides a total metric and one broken down by things like topic and partition. Micrometer will opt to register the most specific ones.

Resolves #1095
Resolves #1096
@shakuzen
Copy link
Member

shakuzen commented Mar 10, 2020

Thank you everyone for the interest in this. This has been implemented by #1835 as an incubating feature in 1.4 (see the KafkaClientMetrics binder). Please try it out (available in snapshots now, soon to be released) and give feedback. With enough feedback, we can promote this to a non-incubating feature.

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

Successfully merging a pull request may close this issue.

7 participants