/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Pushes metrics to CloudWatch. * * @param cloudWatchApi the {@link CloudWatchApi} to use for the request * @param region the region to put the metrics in * @param metrics the metrics to publish * @param namespace the namespace to publish the metrics in */ public static void putMetricData(CloudWatchApi cloudWatchApi, String region, Iterable<MetricDatum> metrics, String namespace) { MetricApi metricApi = cloudWatchApi.getMetricApiForRegion(region); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } }
/** * Tests {@link CloudWatch#putMetricData(CloudWatchApi, String, Iterable, String)} where the set of metrics is * greater than 10. * * @throws Exception if anything goes wrong */ @Test public void testPutMetricData() throws Exception { CloudWatchApi api = createMock(CloudWatchApi.class); MetricApi metricApi = createMock(MetricApi.class); Set<MetricDatum> metrics = Sets.newLinkedHashSet(); String namespace = "JCLOUDS/Test"; for (int i = 0; i < 11; i++) { metrics.add(MetricDatum.builder().metricName("foo").build()); } // Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here expect(api.getMetricApiForRegion(EasyMock.eq(""))) .andReturn(metricApi) .atLeastOnce(); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } EasyMock.replay(api, metricApi); CloudWatch.putMetricData(api, "", metrics, namespace); EasyMock.verify(metricApi); }
/** * Tests {@link CloudWatch#putMetricData(CloudWatchApi, String, Iterable, String)} where the set of metrics is * greater than 10. * * @throws Exception if anything goes wrong */ @Test public void testPutMetricData() throws Exception { CloudWatchApi api = createMock(CloudWatchApi.class); MetricApi metricApi = createMock(MetricApi.class); Set<MetricDatum> metrics = Sets.newLinkedHashSet(); String namespace = "JCLOUDS/Test"; for (int i = 0; i < 11; i++) { metrics.add(MetricDatum.builder().metricName("foo").build()); } // Using EasyMock.eq("") because EasyMock makes it impossible to pass null as a String value here expect(api.getMetricApiForRegion(EasyMock.eq(""))) .andReturn(metricApi) .atLeastOnce(); for (List<MetricDatum> slice : Iterables.partition(metrics, 10)) { metricApi.putMetricsInNamespace(slice, namespace); } EasyMock.replay(api, metricApi); CloudWatch.putMetricData(api, "", metrics, namespace); EasyMock.verify(metricApi); }
.build(); api().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);
metricApi().putMetricsInNamespace(ImmutableSet.of( MetricDatum.builder() .metricName(metricName)
.build(); api().putMetricsInNamespace(ImmutableSet.of(metricDatum, metricDatum2), namespace);
metricApi().putMetricsInNamespace(ImmutableSet.of( MetricDatum.builder() .metricName(metricName)