Skip to content

KAFKA-19711: Add commit-rate metric to metered state stores Add commit metric#21853

Merged
bbejeck merged 3 commits intoapache:trunkfrom
bbejeck:KAFKA-19711_add_commit_metric
Mar 25, 2026
Merged

KAFKA-19711: Add commit-rate metric to metered state stores Add commit metric#21853
bbejeck merged 3 commits intoapache:trunkfrom
bbejeck:KAFKA-19711_add_commit_metric

Conversation

@bbejeck
Copy link
Member

@bbejeck bbejeck commented Mar 23, 2026

Add commit-rate, commit-latency-avg, and commit-latency-max
metrics to replace the flush-* metrics which are now deprecated. The
flush-* metrics will be removed in the next major release.

Reviewers: Eduwer Camacaro eduwerc@gmail.com, Chriso Lolov
clolov@apache.org, Alieh Saeedii asaeedi@confluent.io

Copy link
Contributor

@eduwercamacaro eduwercamacaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 329 to 330
final KafkaMetric metric = metric("flush-rate");
assertTrue((Double) metric.metricValue() > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KIP mentions that while the flush metrics are only deprecated, they will no longer record any data under normal use, as Kafka Streams will no longer call StateStore#flush(), but this test seems to assert on a non-zero value. Is not recording flush metrics a next step?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, no my intent was to do it in one step, that detail of the KIP slipped my mind. I'll update it.

@bbejeck
Copy link
Member Author

bbejeck commented Mar 23, 2026

@clolov I've updated the PR to only record for the commit-X metrics. We need to keep the deprecated flush-X around until the next major release, so I opted to use a dummy value in the init method as workaround for the Spotbugs unused field violation.

Copy link
Contributor

@aliehsaeedii aliehsaeedii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bbejeck. I read the PR description and found it a bit confusing, which is why I left my earlier comment — and it looks like you’ve since updated the code based on another comment. It might be worth updating the PR description as well so they’re consistent.

Also, I couldn’t find the “varargs overload of StreamsMetricsImpl.maybeMeasureLatency” mentioned in the description; perhaps you ended up not needing it since you’re not measuring multiple metrics anymore.

// flushSensor is deprecated per KIP-1035 and will be removed in the next major release.
// Recording a dummy value to avoid a SpotBugs URF_UNREAD_FIELD warning.
flushSensor = StateStoreMetrics.flushSensor(taskId.toString(), metricsScope, name(), streamsMetrics);
flushSensor.record(0.0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states that “both sets of metrics are recorded during the deprecation period for backward compatibility”, but that’s not what the current code actually does.

I understand that the flush method has been removed, but when we talk about backward compatibility, my expectation would be that, until the next major release, both flushSensor and commitSensor should report/represent the same underlying behavior, and only in the next major release would we remove the deprecated flushSensor. That’s just my interpretation/expectation, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, now I know you did not intend to keep the flushSensore behaving the same as before. Just updating PR description is needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aliehsaeedii - I've updated the PR description to reflect the changes made for comments

@bbejeck
Copy link
Member Author

bbejeck commented Mar 25, 2026

@aliehsaeedii I've updated the PR description and removed the flushSensor variable due to deprecation and the fact that we are not recording flush metrics post KIP-1035

Copy link
Contributor

@clolov clolov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thanks for the changes 😊

@bbejeck bbejeck merged commit 153a458 into apache:trunk Mar 25, 2026
22 checks passed
@bbejeck
Copy link
Member Author

bbejeck commented Mar 25, 2026

Merged #21853 into trunk

bbejeck added a commit that referenced this pull request Mar 25, 2026
…t metric (#21853)

Add `commit-rate`, `commit-latency-avg`, and `commit-latency-max`
metrics to replace the `flush-`* metrics which are now deprecated.  The
flush-* metrics will be removed in the next major  release.

Reviewers: Eduwer Camacaro <eduwerc@gmail.com>, Chriso Lolov
 <clolov@apache.org>, Alieh Saeedii <asaeedi@confluent.io>
@bbejeck
Copy link
Member Author

bbejeck commented Mar 25, 2026

cherry-picked to 4.3

@mimaison
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants