XComp commented on code in PR #23737:
URL: https://github.com/apache/flink/pull/23737#discussion_r1396272660
##########
flink-tests/src/test/java/org/apache/flink/test/streaming/runtime/SinkV2MetricsITCase.java:
##########
@@ -228,32 +228,54 @@ private void assertSinkCommitterMetrics(
for (OperatorMetricGroup group : groups) {
Map<String, Metric> metrics = reporter.getMetricsByGroup(group);
- aggregated.merge(
- MetricNames.SUCCESSFUL_COMMITTABLES,
- ((Counter)
metrics.get(MetricNames.SUCCESSFUL_COMMITTABLES)).getCount(),
- Long::sum);
- aggregated.merge(
- MetricNames.ALREADY_COMMITTED_COMMITTABLES,
- ((Counter)
metrics.get(MetricNames.ALREADY_COMMITTED_COMMITTABLES)).getCount(),
- Long::sum);
- aggregated.merge(
- MetricNames.RETRIED_COMMITTABLES,
- ((Counter)
metrics.get(MetricNames.RETRIED_COMMITTABLES)).getCount(),
- Long::sum);
- aggregated.merge(
- MetricNames.FAILED_COMMITTABLES,
- ((Counter)
metrics.get(MetricNames.FAILED_COMMITTABLES)).getCount(),
- Long::sum);
- aggregated.merge(
- MetricNames.TOTAL_COMMITTABLES,
- ((Counter)
metrics.get(MetricNames.TOTAL_COMMITTABLES)).getCount(),
- Long::sum);
- aggregated.merge(
- MetricNames.PENDING_COMMITTABLES,
- ((Gauge<Integer>)
metrics.get(MetricNames.PENDING_COMMITTABLES))
- .getValue()
- .longValue(),
- Long::sum);
+ if (metrics == null) {
+ continue;
+ }
+
+ Counter successCounter = (Counter)
metrics.get(MetricNames.SUCCESSFUL_COMMITTABLES);
+ Counter committedCounter = (Counter)
metrics.get(MetricNames.ALREADY_COMMITTED_COMMITTABLES);
+ Counter retriedCounter = (Counter)
metrics.get(MetricNames.RETRIED_COMMITTABLES);
+ Counter failedCounter = (Counter)
metrics.get(MetricNames.FAILED_COMMITTABLES);
+ Counter totalCounter = (Counter)
metrics.get(MetricNames.TOTAL_COMMITTABLES);
+ Gauge<Integer> pendingMetrics =
+ (Gauge<Integer>)
metrics.get(MetricNames.PENDING_COMMITTABLES);
+
+ if (successCounter != null) {
+ aggregated.merge(
+ MetricNames.SUCCESSFUL_COMMITTABLES,
+ successCounter.getCount(),
+ Long::sum);
+ }
+ if (successCounter != null) {
Review Comment:
```suggestion
if (committerCounter != null) {
```
Thanks for the fix, @pvary . Here I'm not sure, yet. Shouldn't it be based
on the counter that is accessed within the if block? :thinking:
--
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]