-
Notifications
You must be signed in to change notification settings - Fork 347
Add failure metrics to the Kafka source #7088
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,9 @@ public class KafkaTopicConsumerMetrics { | |
| static final String NUMBER_OF_RECORDS_COMMITTED = "numberOfRecordsCommitted"; | ||
| static final String NUMBER_OF_RECORDS_CONSUMED = "numberOfRecordsConsumed"; | ||
| static final String NUMBER_OF_BYTES_CONSUMED = "numberOfBytesConsumed"; | ||
| static final String NUMBER_OF_COMMIT_FAILURES = "numberOfCommitFailures"; | ||
| static final String NUMBER_OF_OFFSET_RESET_FAILURES = "numberOfOffsetResetFailures"; | ||
| static final String NUMBER_OF_BUFFER_WRITE_FAILURES = "numberOfBufferWriteFailures"; | ||
| static final String ACTUAL_POLL_INTERVAL = "actualPollInterval"; | ||
|
|
||
| private final String topicName; | ||
|
|
@@ -49,6 +52,9 @@ public class KafkaTopicConsumerMetrics { | |
| private final Counter numberOfRecordsCommitted; | ||
| private final Counter numberOfRecordsConsumed; | ||
| private final Counter numberOfBytesConsumed; | ||
| private final Counter numberOfCommitFailures; | ||
| private final Counter numberOfOffsetResetFailures; | ||
| private final Counter numberOfBufferWriteFailures; | ||
| private final Timer timeBetweenPollCalls; | ||
| private Instant lastPollTime; | ||
|
|
||
|
|
@@ -69,6 +75,9 @@ public KafkaTopicConsumerMetrics(final String topicName, final PluginMetrics plu | |
| this.numberOfPollAuthErrors = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_POLL_AUTH_ERRORS, topicNameInMetrics)); | ||
| this.numberOfPositiveAcknowledgements = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_POSITIVE_ACKNOWLEDGEMENTS, topicNameInMetrics)); | ||
| this.numberOfNegativeAcknowledgements = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_NEGATIVE_ACKNOWLEDGEMENTS, topicNameInMetrics)); | ||
| this.numberOfCommitFailures = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_COMMIT_FAILURES, topicNameInMetrics)); | ||
| this.numberOfOffsetResetFailures = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_OFFSET_RESET_FAILURES, topicNameInMetrics)); | ||
| this.numberOfBufferWriteFailures = pluginMetrics.counter(getTopicMetricName(NUMBER_OF_BUFFER_WRITE_FAILURES, topicNameInMetrics)); | ||
| this.timeBetweenPollCalls = pluginMetrics.timer(getTopicMetricName(ACTUAL_POLL_INTERVAL, topicNameInMetrics)); | ||
| lastPollTime = Instant.now(); | ||
| } | ||
|
|
@@ -175,6 +184,18 @@ public Counter getNumberOfPositiveAcknowledgements() { | |
| return numberOfPositiveAcknowledgements; | ||
| } | ||
|
|
||
| public Counter getNumberOfCommitFailures() { | ||
| return numberOfCommitFailures; | ||
| } | ||
|
|
||
| public Counter getNumberOfOffsetResetFailures() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name Two details about what it actually counts, in case the name should reflect them:
Because it fires only on the negative-ack redelivery path, a name tied to that path reads more clearly on a dashboard and avoids the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like |
||
| return numberOfOffsetResetFailures; | ||
| } | ||
|
|
||
| public Counter getNumberOfBufferWriteFailures() { | ||
| return numberOfBufferWriteFailures; | ||
| } | ||
|
|
||
| public void recordTimeBetweenPolls() { | ||
| final long timeBetweenPolls = Instant.now().toEpochMilli() - lastPollTime.toEpochMilli(); | ||
| timeBetweenPollCalls.record(timeBetweenPolls, TimeUnit.MILLISECONDS); | ||
|
|
||
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.
This will catch both a seek failure and a commit error. Should these be the same metric?