You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/05/14 08:25:21 UTC
[GitHub] [flink] zentol commented on a change in pull request #12138: [FLINK-16611] [datadog-metrics] Make number of metrics per request configurable
zentol commented on a change in pull request #12138:
URL: https://github.com/apache/flink/pull/12138#discussion_r424957626
##########
File path: flink-metrics/flink-metrics-datadog/src/main/java/org/apache/flink/metrics/datadog/DatadogHttpReporter.java
##########
@@ -157,6 +181,11 @@ private void addGaugesAndUnregisterOnException(DSeries request) {
// Flink uses Gauge to store many types other than Number
g.getMetricValue();
request.addGauge(g);
+ ++currentCount;
+ if (currentCount % maxMetricsPerRequestValue == 0 || currentCount >= totalGauges) {
+ client.send(request);
Review comment:
hmm, I don't really like that we're always sending at least 2 requests, as long as at least one counter and gauge exist.
Ultimately, all we need to do is slice the currently created `DSeries`, which we could do using `ArrayList#subList`.
```
int fromIndex = 0;
ArrayList<DMetric> series = request.getSeries();
while (fromIndex < series.size()) {
int toIndex = Math.Min(currentCount + maxMetricsPerRequestValue, series.size());
client.send(series.subList(fromIndex, toIndex));
fromIndex = toIndex;
}
```
WDYT? We could even wrap this logic into a stateful `Consumer` that resets the `DSeries` on each `client.send`, so we don't have to assemble the full list.
----------------------------------------------------------------
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:
users@infra.apache.org