Commit 779638be authored by peng-yongsheng's avatar peng-yongsheng
Browse files

Trace stack ui with elasticsearch storage provider test success.

parent 085da839
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -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));
+17 −1
Original line number Diff line number Diff line
@@ -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;
    }
}