Skip to content

Commit 0a7c7b3

Browse files
authored
add test to add multiple CloudWatch metrics/dimentions in a single request (#30)
1 parent 755a9e6 commit 0a7c7b3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/test/java/cloud/localstack/awssdkv2/BasicFeaturesSDKV2Test.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,39 @@ public void testCWPutMetrics() throws Exception {
174174
PutMetricDataResponse response = clientCW.putMetricData(request).get();
175175
Assert.assertNotNull(response);
176176
}
177+
178+
@Test
179+
public void testCWMultipleDimentionsAndMetrics() throws Exception {
180+
final CloudWatchAsyncClient clientCW = TestUtils.getClientCloudWatchAsyncV2();
181+
182+
List<Dimension> awsDimensionList = new ArrayList<>();
183+
for (int i = 0; i < 10; i++) {
184+
awsDimensionList.add(Dimension.builder()
185+
.name("UNIQUE_PAGES"+i)
186+
.value("URLS"+i)
187+
.build());
188+
};
189+
190+
// Set an Instant object
191+
String time = ZonedDateTime.now( ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT );
192+
Instant instant = Instant.parse(time);
193+
double dataPoint = 1.23423;
194+
195+
List<MetricDatum> metrics = new ArrayList();
196+
for (int i = 0; i < 20; i++) {
197+
metrics.add(MetricDatum.builder()
198+
.metricName("PAGES_VISITED")
199+
.unit(StandardUnit.NONE)
200+
.value(dataPoint)
201+
.timestamp(instant)
202+
.dimensions(awsDimensionList).build());
203+
};
204+
205+
PutMetricDataRequest request = PutMetricDataRequest.builder()
206+
.namespace("SITE/TRAFFIC")
207+
.metricData(metrics).build();
208+
209+
PutMetricDataResponse response = clientCW.putMetricData(request).get();
210+
Assert.assertNotNull(response);
211+
}
177212
}

0 commit comments

Comments
 (0)