Skip to content

Commit

Permalink
Trace stack ui with elasticsearch storage provider test success.
Browse files Browse the repository at this point in the history
  • Loading branch information
peng-yongsheng committed Nov 15, 2017
1 parent 085da83 commit 779638b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ public SegmentCostEsUIDAO(ElasticSearchClient client) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -53,6 +58,17 @@ public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCo
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;
}
}

0 comments on commit 779638b

Please sign in to comment.