Trace stack ui with elasticsearch storage provider test success.

This commit is contained in:
peng-yongsheng 2017-11-16 00:29:31 +08:00
parent 085da8394e
commit 779638bea0
2 changed files with 17 additions and 8 deletions

View File

@ -108,13 +108,6 @@ public class SegmentCostEsUIDAO extends EsDAO implements ISegmentCostUIDAO {
topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME));
}
//TODO IGlobalTraceUIDAO
// IGlobalTraceUIDAO globalTraceDAO = (IGlobalTraceDAO)DAOContainer.INSTANCE.get(IGlobalTraceDAO.class.getName());
// List<String> globalTraces = globalTraceDAO.getGlobalTraceId(segmentId);
// if (CollectionUtils.isNotEmpty(globalTraces)) {
// topSegmentJson.addProperty(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraces.get(0));
// }
topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_APPLICATION_ID));
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SERVICE_NAME));
topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_COST));

View File

@ -18,14 +18,19 @@
package org.skywalking.apm.collector.ui.service;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.util.LinkedList;
import java.util.List;
import org.skywalking.apm.collector.core.module.ModuleManager;
import org.skywalking.apm.collector.core.util.CollectionUtils;
import org.skywalking.apm.collector.core.util.StringUtils;
import org.skywalking.apm.collector.storage.StorageModule;
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
import org.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO;
import org.skywalking.apm.collector.storage.table.global.GlobalTraceTable;
import org.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,6 +58,17 @@ public class SegmentTopService {
if (StringUtils.isNotEmpty(globalTraceId)) {
segmentIds = globalTraceDAO.getSegmentIds(globalTraceId);
}
return segmentCostDAO.loadTop(startTime, endTime, minCost, maxCost, operationName, error, applicationId, segmentIds, limit, from, sort);
JsonObject loadTopJsonObj = segmentCostDAO.loadTop(startTime, endTime, minCost, maxCost, operationName, error, applicationId, segmentIds, limit, from, sort);
JsonArray loadTopJsonArray = loadTopJsonObj.get("data").getAsJsonArray();
for (JsonElement loadTopElement : loadTopJsonArray) {
JsonObject jsonObject = loadTopElement.getAsJsonObject();
String segmentId = jsonObject.get(SegmentCostTable.COLUMN_SEGMENT_ID).getAsString();
List<String> globalTraces = globalTraceDAO.getGlobalTraceId(segmentId);
if (CollectionUtils.isNotEmpty(globalTraces)) {
jsonObject.addProperty(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraces.get(0));
}
}
return loadTopJsonObj;
}
}