@NotThreadSafe public class MetricCollectionAggregator extends Object
MetricCollections by: (1) the minute in which they occurred, and (2) the dimensions in the collection
associated with that metric. Allows retrieving the aggregated values as a list of PutMetricDataRequests.
It would be too expensive to upload every MetricCollection as a unique PutMetricDataRequest, so this
class aggregates the data so that multiple MetricCollections can be placed in the same PutMetricDataRequest.
Warning: This class is *not* thread-safe.
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_METRIC_DATA_PER_REQUEST
The maximum number of
MetricDatums allowed in PutMetricDataRequest.metricData(). |
static int |
MAX_VALUES_PER_REQUEST
The maximum number of unique
MetricDatum.values() allowed in a single PutMetricDataRequest. |
| Constructor and Description |
|---|
MetricCollectionAggregator(String namespace,
Set<SdkMetric<String>> dimensions,
Set<MetricCategory> metricCategories,
MetricLevel metricLevel,
Set<SdkMetric<?>> detailedMetrics) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCollection(MetricCollection collection)
Add a collection to this aggregator.
|
List<PutMetricDataRequest> |
getRequests()
Get all
PutMetricDataRequests that can be generated from the data that was added via
addCollection(MetricCollection). |
public static final int MAX_METRIC_DATA_PER_REQUEST
MetricDatums allowed in PutMetricDataRequest.metricData(). This limit is imposed by
CloudWatch.public static final int MAX_VALUES_PER_REQUEST
MetricDatum.values() allowed in a single PutMetricDataRequest. This limit is
not imposed directly by CloudWatch, but they do impose a 40KB limit for a single request. This value was determined by
trial-and-error to roughly equate to a 40KB limit when we are also at the MAX_METRIC_DATA_PER_REQUEST.public MetricCollectionAggregator(String namespace, Set<SdkMetric<String>> dimensions, Set<MetricCategory> metricCategories, MetricLevel metricLevel, Set<SdkMetric<?>> detailedMetrics)
public void addCollection(MetricCollection collection)
public List<PutMetricDataRequest> getRequests()
PutMetricDataRequests that can be generated from the data that was added via
addCollection(MetricCollection). This method resets the state of this MetricCollectionAggregator.Copyright © 2023. All rights reserved.