提交 08d26eca 编写于 作者: P peng-yongsheng

Change the traceId type to be collection in trace graphql protocol.

上级 a498a91f
......@@ -18,15 +18,32 @@
package org.apache.skywalking.apm.collector.storage.ui.trace;
import java.util.LinkedList;
import java.util.List;
/**
* @author peng-yongsheng
*/
public class BasicTrace {
private String segmentId;
private String operationName;
private int duration;
private long start;
private Boolean isError;
private String traceId;
private List<String> traceIds;
public String getSegmentId() {
return segmentId;
}
public void setSegmentId(String segmentId) {
this.segmentId = segmentId;
}
public BasicTrace() {
this.traceIds = new LinkedList<>();
}
public String getOperationName() {
return operationName;
......@@ -60,11 +77,11 @@ public class BasicTrace {
isError = error;
}
public String getTraceId() {
return traceId;
public List<String> getTraceIds() {
return traceIds;
}
public void setTraceId(String traceId) {
this.traceId = traceId;
public void setTraceIds(List<String> traceIds) {
this.traceIds = traceIds;
}
}
......@@ -91,7 +91,7 @@ public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUID
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
BasicTrace basicTrace = new BasicTrace();
basicTrace.setTraceId((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_TRACE_ID));
basicTrace.setSegmentId((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_SEGMENT_ID));
basicTrace.setStart(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_START_TIME)).longValue());
basicTrace.setOperationName((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_SERVICE_NAME));
basicTrace.setDuration(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_DURATION)).intValue());
......
......@@ -101,9 +101,9 @@ public class SegmentDurationH2UIDAO extends H2DAO implements ISegmentDurationUID
try (ResultSet rs = client.executeQuery(sql, p)) {
while (rs.next()) {
BasicTrace basicTrace = new BasicTrace();
basicTrace.setSegmentId(rs.getString(SegmentDurationTable.COLUMN_SEGMENT_ID));
basicTrace.setDuration(rs.getInt(SegmentDurationTable.COLUMN_DURATION));
basicTrace.setStart(rs.getLong(SegmentDurationTable.COLUMN_START_TIME));
basicTrace.setTraceId(rs.getString(SegmentDurationTable.COLUMN_TRACE_ID));
basicTrace.setOperationName(rs.getString(SegmentDurationTable.COLUMN_SERVICE_NAME));
basicTrace.setError(BooleanUtils.valueToBoolean(rs.getInt(SegmentDurationTable.COLUMN_IS_ERROR)));
traceBrief.getTraces().add(basicTrace);
......
......@@ -51,11 +51,19 @@ public class SegmentTopService {
startSecondTimeBucket, endSecondTimeBucket, minDuration,
maxDuration, operationName, traceId, applicationId, limit, from);
TraceBrief traceBrief;
if (StringUtils.isNotEmpty(traceId)) {
List<String> segmentIds = globalTraceUIDAO.getSegmentIds(traceId);
return segmentDurationUIDAO.loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, applicationId, limit, from, segmentIds.toArray(new String[0]));
traceBrief = segmentDurationUIDAO.loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, applicationId, limit, from, segmentIds.toArray(new String[0]));
} else {
return segmentDurationUIDAO.loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, applicationId, limit, from);
traceBrief = segmentDurationUIDAO.loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, applicationId, limit, from);
}
traceBrief.getTraces().forEach(trace -> {
List<String> traceIds = globalTraceUIDAO.getGlobalTraceId(trace.getSegmentId());
trace.getTraceIds().addAll(traceIds);
});
return traceBrief;
}
}
......@@ -10,7 +10,7 @@ type BasicTrace {
duration: Int!
start: String!
isError: Boolean
traceId: String
traceIds: [String!]!
}
# Represent the conditions used for query TraceBrief
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册