-
Notifications
You must be signed in to change notification settings - Fork 867
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 kafka client metrics #6138
Add kafka client metrics #6138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review in the project
...library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/KafkaMetricRegistry.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/KafkaMetricRegistry.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetricsTest.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
100% agree with that 👍 The only thing that I'm slightly worried about is that we won't expose metrics that are common to all messaging clients (like the HTTP client/server metrics; think |
...library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/KafkaMetricRegistry.java
Outdated
Show resolved
Hide resolved
Thanks for the review @mateuszrzeszutek!
👍 My thinking is that bridging these metrics does not prevent us from later adding additional metrics which have consistency with other messaging systems. |
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
and `[client-id, topic]`. If you analyze the sum of records consumed, ignoring dimensions, backends | ||
are likely to double count. To alleviate this, `OpenTelemetryKafkaMetrics` detects this | ||
scenario and only records the most granular set of attributes available. In the case | ||
of `records-consumed-total`, it reports `[client-id, topic]` and ignores `[client-id]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a commit with new logic that does what's described in this comment. I think its a fairly important improvement.
it.remove(); | ||
} else if (curRegisteredObservable.getInstrumentDescriptor().equals(instrumentDescriptor) | ||
&& attributeKeys.size() > curAttributeKeys.size() | ||
&& attributeKeys.containsAll(curAttributeKeys)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how I detect whether a metric exists with less granular set of attribute keys, as explained in this part of the readme.
In the process of adding support for this, I shuffled some stuff around for better organization, including moving the table print method to OpenTelemetryKafkaMetricTest
. It turns out that all the information needed to print the table can be obtained without any additional surface area.
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
instrumentation/kafka/kafka-clients/kafka-clients-0.11/testing/build.gradle.kts
Outdated
Show resolved
Hide resolved
instrumentation/kafka/kafka-clients/kafka-clients-common/library/README.md
Outdated
Show resolved
Hide resolved
instrumentation/kafka/kafka-clients/kafka-clients-common/library/README.md
Outdated
Show resolved
Hide resolved
...library/src/main/java/io/opentelemetry/instrumentation/kafkaclients/KafkaMetricRegistry.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx!
...ing/src/main/groovy/io/opentelemetry/instrumentation/kafkaclients/KafkaClientBaseTest.groovy
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/opentelemetry/instrumentation/kafkaclients/OpenTelemetryKafkaMetrics.java
Outdated
Show resolved
Hide resolved
* <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
* at any time. | ||
*/ | ||
public class OpenTelemetryMetricsReporter implements MetricsReporter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anuraaga unfortunately this has to be public, so I've moved it to an internal class.
...ava/io/opentelemetry/instrumentation/kafkaclients/internal/OpenTelemetryMetricsReporter.java
Outdated
Show resolved
Hide resolved
instrumentation/kafka/kafka-clients/kafka-clients-common/library/README.md
Outdated
Show resolved
Hide resolved
thx @jack-berg! |
Proposal to bridge metrics from the kafka client library into OpenTelemetry.
As this PR currently stands, only metrics which align with those already declared in the kafka metric semantic convention are bridged. However, the semantic conventions are focused around the use case of monitoring kafka brokers, rather than clients. There's a lot more useful data available, which I'd like the semantic conventions to be extended with.I've added a utility that makes it easier to explore which metrics are available, and if / how they're mapped into OpenTelemetry metrics. The utility prints out all this info in a markdown table, which I've included in the README.
I could use some feedback about:
** Updated 6/8/22 **
I've updated the PR to be a general purpose bridge between kafka client metrics and opentelemetry metric, rather than implementing as an allow list of known metrics. My reasoning is as follows: