zentol commented on a change in pull request #11483: 
[FLINK-15438][metrics][datadog] Report counter deltas and not totals
URL: https://github.com/apache/flink/pull/11483#discussion_r397774214
 
 

 ##########
 File path: 
flink-metrics/flink-metrics-datadog/src/main/java/org/apache/flink/metrics/datadog/DCounter.java
 ##########
 @@ -28,17 +28,34 @@
 public class DCounter extends DMetric {
        private final Counter counter;
 
+       private long lastReportedValue = 0;
 
 Review comment:
   I think we can simplify this mechanism a bit; my suggestion would be:
   ```
   public class DCounter extends DMetric {
        ...
        private long lastReportCount = 0;
        private long currentReportCount = 0;
        ...
        public Number getMetricValue() {
                long currentCount = counter.getCount();
                long difference = currentCount - lastReportCount;
                currentReportCount = currentCount;
                return difference;
        }
   
        public void ackReport() {
                lastReportCount = currentReportCount;
        }
   }
   
   public class DatadogHttpReporter ... {
        ...
        public void report() {
                ...
                counters.values().forEach(request::addCounter);
                ...
                try {
                        client.send(request);
                        counters.values().forEach(request::ackReport);
                } ...
        }
   }
   ```
   
   This way we don't assemble another map, we have less of a back-and-forth 
between the reporter/metric and the error handling remains as is.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to