@@ -92,17 +92,12 @@ public void validate() throws Exception {
92
92
maxRetryCount ,
93
93
() -> {
94
94
95
- // Special handling for Genesis path - just check if any metrics exist in namespace
96
- // since ADOT will just capture any OTel Metrics emitted and convert them into EMF metrics, it's impossible to create
95
+ // Special handling for Genesis path - just check if any metrics exists in namespace
96
+ // since ADOT will just capture any OTel Metrics from the emitted from the instrumentation library
97
+ // and convert them into EMF metrics, it's impossible to create
97
98
// a validation template for this.
98
99
if (validationConfig .getHttpPath ().contains ("ai-chat" )) {
99
-
100
- List <Metric > allMetricsInNamespace = cloudWatchService .listMetrics (context .getMetricNamespace (), null , null , null );
101
- log .info ("Found {} metrics in namespace {}" , allMetricsInNamespace .size (), context .getMetricNamespace ());
102
- if (allMetricsInNamespace .isEmpty ()) {
103
- throw new BaseException (ExceptionCode .EXPECTED_METRIC_NOT_FOUND , "No metrics found in namespace: " + context .getMetricNamespace ());
104
- }
105
- log .info ("validation is passed for path {}" , validationConfig .getHttpPath ());
100
+ validateAnyMetricExists ();
106
101
return ;
107
102
}
108
103
// We will query the Service, RemoteService, and RemoteTarget dimensions to ensure we
@@ -224,6 +219,17 @@ private void compareMetricLists(List<Metric> expectedMetricList, List<Metric> ac
224
219
matchAny .stream ().findAny ().get (), actualMetricSnapshot ));
225
220
}
226
221
}
222
+
223
+ private void validateAnyMetricExists () throws Exception {
224
+ // This will grab all metrics from last 3 hours
225
+ // See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html
226
+ List <Metric > allMetricsInNamespace = cloudWatchService .listMetrics (context .getMetricNamespace (), null , null , null );
227
+ log .info ("Found {} metrics in namespace {}" , allMetricsInNamespace .size (), context .getMetricNamespace ());
228
+ if (allMetricsInNamespace .isEmpty ()) {
229
+ throw new BaseException (ExceptionCode .EXPECTED_METRIC_NOT_FOUND , "No metrics found in namespace: " + context .getMetricNamespace ());
230
+ }
231
+ log .info ("validation is passed for path {}" , validationConfig .getHttpPath ());
232
+ }
227
233
228
234
private List <Metric > listMetricFromCloudWatch (
229
235
CloudWatchService cloudWatchService ,
0 commit comments