use of software.amazon.awssdk.services.cloudwatch.model.Datapoint in project beam by apache.
the class SimplifiedKinesisClient method getBacklogBytes.
/**
* Gets total size in bytes of all events that remain in Kinesis stream between specified
* instants.
*
* @return total size in bytes of all Kinesis events after specified instant
*/
public long getBacklogBytes(final String streamName, final Instant countSince, final Instant countTo) throws TransientKinesisException {
return wrapExceptions(() -> {
Minutes period = Minutes.minutesBetween(countSince, countTo);
if (period.isLessThan(Minutes.ONE)) {
return 0L;
}
GetMetricStatisticsRequest request = createMetricStatisticsRequest(streamName, countSince, countTo, period);
long totalSizeInBytes = 0;
GetMetricStatisticsResponse response = cloudWatch.getMetricStatistics(request);
for (Datapoint point : response.datapoints()) {
totalSizeInBytes += point.sum().longValue();
}
return totalSizeInBytes;
});
}
Aggregations