Skip to content

Commit 4dfb10d

Browse files
committed
test
1 parent 0c346ec commit 4dfb10d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

validator/src/main/java/com/amazon/aoc/validators/TraceValidator.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,13 @@ private Map<String, Object> getTrace() throws Exception {
149149
}
150150

151151
if (validationConfig.getHttpPath().contains("chat")) {
152-
// For chat endpoints, directly use the trace ID instead of searching
153-
List<String> traceIdLists = Collections.singletonList(context.getTraceId());
154-
List<Trace> retrievedTraceList = xrayService.listTraceByIds(traceIdLists);
155-
if (retrievedTraceList == null || retrievedTraceList.isEmpty()) {
156-
throw new BaseException(ExceptionCode.EMPTY_LIST);
157-
}
158-
return this.flattenDocument(retrievedTraceList.get(0).getSegments());
152+
return this.getTraceById(Collections.singletonList(context.getTraceId()));
159153
}
154+
160155
log.info("Trace Filter: {}", traceFilter);
161156
List<TraceSummary> retrieveTraceLists = xrayService.searchTraces(traceFilter);
162157
List<String> traceIdLists = Collections.singletonList(retrieveTraceLists.get(0).getId());
163-
List<Trace> retrievedTraceList = xrayService.listTraceByIds(traceIdLists);
164-
165-
if (retrievedTraceList == null || retrievedTraceList.isEmpty()) {
166-
throw new BaseException(ExceptionCode.EMPTY_LIST);
167-
}
168-
return this.flattenDocument(retrievedTraceList.get(0).getSegments());
158+
return getTraceById(traceIdLists);
169159
}
170160

171161
private Map<String, Object> flattenDocument(List<Segment> segmentList) {
@@ -200,6 +190,14 @@ private Map<String, Object> flattenDocument(List<Segment> segmentList) {
200190
return JsonFlattener.flattenAsMap(segmentsJson.toString());
201191
}
202192

193+
private Map<String, Object> getTraceById(List<String> traceIdLists) throws Exception {
194+
List<Trace> retrievedTraceList = xrayService.listTraceByIds(traceIdLists);
195+
if (retrievedTraceList == null || retrievedTraceList.isEmpty()) {
196+
throw new BaseException(ExceptionCode.EMPTY_LIST);
197+
}
198+
return this.flattenDocument(retrievedTraceList.get(0).getSegments());
199+
}
200+
203201
// This method will get the stored traces
204202
private Map<String, Object> getStoredTrace() throws Exception {
205203
Map<String, Object> flattenedJsonMapForStoredTraces = null;

0 commit comments

Comments
 (0)