@@ -149,23 +149,13 @@ private Map<String, Object> getTrace() throws Exception {
149
149
}
150
150
151
151
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 ()));
159
153
}
154
+
160
155
log .info ("Trace Filter: {}" , traceFilter );
161
156
List <TraceSummary > retrieveTraceLists = xrayService .searchTraces (traceFilter );
162
157
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 );
169
159
}
170
160
171
161
private Map <String , Object > flattenDocument (List <Segment > segmentList ) {
@@ -200,6 +190,14 @@ private Map<String, Object> flattenDocument(List<Segment> segmentList) {
200
190
return JsonFlattener .flattenAsMap (segmentsJson .toString ());
201
191
}
202
192
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
+
203
201
// This method will get the stored traces
204
202
private Map <String , Object > getStoredTrace () throws Exception {
205
203
Map <String , Object > flattenedJsonMapForStoredTraces = null ;
0 commit comments