gemini-code-assist[bot] commented on code in PR #38889:
URL: https://github.com/apache/beam/pull/38889#discussion_r3387299550
##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaCommitOffset.java:
##########
@@ -62,6 +64,9 @@ public class KafkaCommitOffset<K, V>
static class CommitOffsetDoFn extends DoFn<KV<KafkaSourceDescriptor, Long>,
Void> {
private static final Logger LOG =
LoggerFactory.getLogger(CommitOffsetDoFn.class);
+ private final Counter commitFailures =
+ Metrics.counter(CommitOffsetDoFn.class, "commit-failures");
Review Comment:

In Apache Beam, it is a best practice to declare `Counter` metrics as
`static final` rather than instance variables. This avoids unnecessary object
creation per `DoFn` instance and prevents serialization overhead, as metrics
are registered globally per class namespace. Additionally, static final fields
should follow the screaming snake case naming convention (e.g.,
`COMMIT_FAILURES`).
```suggestion
private static final Counter COMMIT_FAILURES =
Metrics.counter(CommitOffsetDoFn.class, "commit-failures");
```
##########
sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaCommitOffset.java:
##########
@@ -85,6 +90,7 @@ public void processElement(@Element KV<KafkaSourceDescriptor,
Long> element) {
element.getKey().getTopicPartition(),
new OffsetAndMetadata(element.getValue() + 1)));
} catch (Exception e) {
+ commitFailures.inc();
Review Comment:

Update the counter reference to use the static final `COMMIT_FAILURES`
constant.
```suggestion
COMMIT_FAILURES.inc();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]