Skip to content

Commit e32dc78

Browse files
phipagclaude
andcommitted
fix: also pad high-resolution metric query window
The high-res metric query (period=1s) also fails with the original 1-minute window due to CloudWatch eventual consistency. Apply the same padded window and sum all returned data points, since only the high-resolution metric appears at 1-second granularity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 38c7a4d commit e32dc78

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/MetricsE2ET.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ void test_recordMetrics() {
119119
"products", Collections.singletonMap("Service", SERVICE));
120120
assertThat(productMetrics.get(0)).isEqualTo(12);
121121

122-
List<Double> productMetricDataResult = metricsFetcher.fetchMetrics(invocationResult.getStart(),
123-
invocationResult.getEnd(), 1, NAMESPACE,
122+
List<Double> productMetricDataResult = metricsFetcher.fetchMetrics(paddedStart,
123+
paddedEnd, 1, NAMESPACE,
124124
"products", Collections.singletonMap("Environment", "test"));
125125

126-
// We are searching across the time period the metric was created but with a period of 1 second. Only the high
127-
// resolution metric will be available at this point
128-
assertThat(productMetricDataResult.get(0)).isEqualTo(8);
126+
// With a period of 1 second, only the high resolution metric is available.
127+
// Sum all data points as the padded window may return multiple 1-second buckets.
128+
double highResSum = productMetricDataResult.stream().mapToDouble(Double::doubleValue).sum();
129+
assertThat(highResSum).isEqualTo(8);
129130
}
130131
}

0 commit comments

Comments
 (0)