Provide the queryBasicTraces query.
This commit is contained in:
parent
8cfadaa0c6
commit
77f615a8ae
|
|
@ -33,7 +33,7 @@ public class MetricGraphIdDefine {
|
|||
public static final int APPLICATION_COMPONENT_GRAPH_ID = 406;
|
||||
public static final int APPLICATION_MAPPING_GRAPH_ID = 407;
|
||||
public static final int GLOBAL_TRACE_GRAPH_ID = 409;
|
||||
public static final int SEGMENT_COST_GRAPH_ID = 410;
|
||||
public static final int SEGMENT_DURATION_GRAPH_ID = 410;
|
||||
public static final int INSTANCE_MAPPING_GRAPH_ID = 411;
|
||||
|
||||
public static final int INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID = 412;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class MetricWorkerIdDefine {
|
|||
public static final int APPLICATION_COMPONENT_MONTH_TRANSFORM_NODE_ID = 4908;
|
||||
|
||||
public static final int GLOBAL_TRACE_PERSISTENCE_WORKER_ID = 427;
|
||||
public static final int SEGMENT_COST_PERSISTENCE_WORKER_ID = 428;
|
||||
public static final int SEGMENT_DURATION_PERSISTENCE_WORKER_ID = 428;
|
||||
|
||||
public static final int INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 429;
|
||||
public static final int APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 430;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.insta
|
|||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric.InstanceMetricGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric.InstanceReferenceMetricGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostSpanListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentDurationGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentDurationSpanListener;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric.ServiceMetricGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricGraph;
|
||||
import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricSpanListener;
|
||||
|
|
@ -93,7 +93,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider {
|
|||
segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory());
|
||||
segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory());
|
||||
segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory());
|
||||
segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory());
|
||||
segmentParserListenerRegister.register(new SegmentDurationSpanListener.Factory());
|
||||
}
|
||||
|
||||
private void graphCreate(WorkerCreateListener workerCreateListener) {
|
||||
|
|
@ -127,8 +127,8 @@ public class AnalysisMetricModuleProvider extends ModuleProvider {
|
|||
GlobalTraceGraph globalTraceGraph = new GlobalTraceGraph(getManager(), workerCreateListener);
|
||||
globalTraceGraph.create();
|
||||
|
||||
SegmentCostGraph segmentCostGraph = new SegmentCostGraph(getManager(), workerCreateListener);
|
||||
segmentCostGraph.create();
|
||||
SegmentDurationGraph segmentDurationGraph = new SegmentDurationGraph(getManager(), workerCreateListener);
|
||||
segmentDurationGraph.create();
|
||||
|
||||
InstanceHeartBeatPersistenceGraph instanceHeartBeatPersistenceGraph = new InstanceHeartBeatPersistenceGraph(getManager(), workerCreateListener);
|
||||
instanceHeartBeatPersistenceGraph.create();
|
||||
|
|
|
|||
|
|
@ -22,23 +22,23 @@ import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGr
|
|||
import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostGraph {
|
||||
public class SegmentDurationGraph {
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private final WorkerCreateListener workerCreateListener;
|
||||
|
||||
public SegmentCostGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
public SegmentDurationGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.workerCreateListener = workerCreateListener;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class)
|
||||
.addNode(new SegmentCostPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SEGMENT_DURATION_GRAPH_ID, SegmentDuration.class)
|
||||
.addNode(new SegmentDurationPersistenceWorker.Factory(moduleManager).create(workerCreateListener));
|
||||
}
|
||||
}
|
||||
|
|
@ -24,20 +24,20 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.impl.Persistenc
|
|||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostPersistenceWorker extends PersistenceWorker<SegmentCost> {
|
||||
public class SegmentDurationPersistenceWorker extends PersistenceWorker<SegmentDuration> {
|
||||
|
||||
public SegmentCostPersistenceWorker(ModuleManager moduleManager) {
|
||||
SegmentDurationPersistenceWorker(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public int id() {
|
||||
return MetricWorkerIdDefine.SEGMENT_COST_PERSISTENCE_WORKER_ID;
|
||||
return MetricWorkerIdDefine.SEGMENT_DURATION_PERSISTENCE_WORKER_ID;
|
||||
}
|
||||
|
||||
@Override protected boolean needMergeDBData() {
|
||||
|
|
@ -45,18 +45,18 @@ public class SegmentCostPersistenceWorker extends PersistenceWorker<SegmentCost>
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override protected IPersistenceDAO<?, ?, SegmentCost> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class);
|
||||
@Override protected IPersistenceDAO<?, ?, SegmentDuration> persistenceDAO() {
|
||||
return getModuleManager().find(StorageModule.NAME).getService(ISegmentDurationPersistenceDAO.class);
|
||||
}
|
||||
|
||||
public static class Factory extends PersistenceWorkerProvider<SegmentCost, SegmentCostPersistenceWorker> {
|
||||
public static class Factory extends PersistenceWorkerProvider<SegmentDuration, SegmentDurationPersistenceWorker> {
|
||||
|
||||
public Factory(ModuleManager moduleManager) {
|
||||
super(moduleManager);
|
||||
}
|
||||
|
||||
@Override public SegmentCostPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new SegmentCostPersistenceWorker(moduleManager);
|
||||
@Override public SegmentDurationPersistenceWorker workerInstance(ModuleManager moduleManager) {
|
||||
return new SegmentDurationPersistenceWorker(moduleManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -35,46 +35,46 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
|||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListener, LocalSpanListener, FirstSpanListener {
|
||||
public class SegmentDurationSpanListener implements EntrySpanListener, ExitSpanListener, LocalSpanListener, FirstSpanListener {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentCostSpanListener.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentDurationSpanListener.class);
|
||||
|
||||
private final List<SegmentCost> segmentCosts;
|
||||
private final List<SegmentDuration> segmentDurations;
|
||||
private final ServiceNameCacheService serviceNameCacheService;
|
||||
private boolean isError = false;
|
||||
private long timeBucket;
|
||||
|
||||
public SegmentCostSpanListener(ModuleManager moduleManager) {
|
||||
this.segmentCosts = new ArrayList<>();
|
||||
SegmentDurationSpanListener(ModuleManager moduleManager) {
|
||||
this.segmentDurations = new ArrayList<>();
|
||||
this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId,
|
||||
String segmentId) {
|
||||
timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime());
|
||||
timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(spanDecorator.getStartTime());
|
||||
|
||||
SegmentCost segmentCost = new SegmentCost();
|
||||
segmentCost.setId(segmentId);
|
||||
segmentCost.setSegmentId(segmentId);
|
||||
segmentCost.setApplicationId(applicationId);
|
||||
segmentCost.setCost(spanDecorator.getEndTime() - spanDecorator.getStartTime());
|
||||
segmentCost.setStartTime(spanDecorator.getStartTime());
|
||||
segmentCost.setEndTime(spanDecorator.getEndTime());
|
||||
SegmentDuration segmentDuration = new SegmentDuration();
|
||||
segmentDuration.setId(segmentId);
|
||||
segmentDuration.setSegmentId(segmentId);
|
||||
segmentDuration.setApplicationId(applicationId);
|
||||
segmentDuration.setDuration(spanDecorator.getEndTime() - spanDecorator.getStartTime());
|
||||
segmentDuration.setStartTime(spanDecorator.getStartTime());
|
||||
segmentDuration.setEndTime(spanDecorator.getEndTime());
|
||||
if (spanDecorator.getOperationNameId() == 0) {
|
||||
segmentCost.setServiceName(spanDecorator.getOperationName());
|
||||
segmentDuration.setServiceName(spanDecorator.getOperationName());
|
||||
} else {
|
||||
segmentCost.setServiceName(serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId())));
|
||||
segmentDuration.setServiceName(serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId())));
|
||||
}
|
||||
|
||||
segmentCosts.add(segmentCost);
|
||||
segmentDurations.add(segmentDuration);
|
||||
isError = isError || spanDecorator.getIsError();
|
||||
}
|
||||
|
||||
|
|
@ -96,18 +96,18 @@ public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListe
|
|||
}
|
||||
|
||||
@Override public void build() {
|
||||
Graph<SegmentCost> graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class);
|
||||
Graph<SegmentDuration> graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_DURATION_GRAPH_ID, SegmentDuration.class);
|
||||
logger.debug("segment cost listener build");
|
||||
for (SegmentCost segmentCost : segmentCosts) {
|
||||
segmentCost.setIsError(BooleanUtils.booleanToValue(isError));
|
||||
segmentCost.setTimeBucket(timeBucket);
|
||||
graph.start(segmentCost);
|
||||
for (SegmentDuration segmentDuration : segmentDurations) {
|
||||
segmentDuration.setIsError(BooleanUtils.booleanToValue(isError));
|
||||
segmentDuration.setTimeBucket(timeBucket);
|
||||
graph.start(segmentDuration);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Factory implements SpanListenerFactory {
|
||||
@Override public SpanListener create(ModuleManager moduleManager) {
|
||||
return new SegmentCostSpanListener(moduleManager);
|
||||
return new SegmentDurationSpanListener(moduleManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,18 +34,18 @@ ui:
|
|||
host: localhost
|
||||
port: 12800
|
||||
context_path: /
|
||||
#storage:
|
||||
# elasticsearch:
|
||||
# cluster_name: CollectorDBCluster
|
||||
# cluster_transport_sniffer: true
|
||||
# cluster_nodes: localhost:9300
|
||||
# index_shards_number: 2
|
||||
# index_replicas_number: 0
|
||||
# ttl: 7
|
||||
storage:
|
||||
h2:
|
||||
url: jdbc:h2:tcp://localhost/~/test
|
||||
user_name: sa
|
||||
elasticsearch:
|
||||
cluster_name: CollectorDBCluster
|
||||
cluster_transport_sniffer: true
|
||||
cluster_nodes: localhost:9300
|
||||
index_shards_number: 2
|
||||
index_replicas_number: 0
|
||||
ttl: 7
|
||||
#storage:
|
||||
# h2:
|
||||
# url: jdbc:h2:tcp://localhost/~/test
|
||||
# user_name: sa
|
||||
configuration:
|
||||
default:
|
||||
application_apdex_threshold: 2000
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.skywalking.apm.collector.core.module.Module;
|
|||
import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO;
|
||||
|
|
@ -113,7 +113,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO;
|
||||
|
|
@ -197,7 +197,7 @@ public class StorageModule extends Module {
|
|||
classes.add(IInstanceMappingMonthPersistenceDAO.class);
|
||||
|
||||
classes.add(IGlobalTracePersistenceDAO.class);
|
||||
classes.add(ISegmentCostPersistenceDAO.class);
|
||||
classes.add(ISegmentDurationPersistenceDAO.class);
|
||||
classes.add(ISegmentPersistenceDAO.class);
|
||||
classes.add(IInstanceHeartBeatPersistenceDAO.class);
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ public class StorageModule extends Module {
|
|||
classes.add(IApplicationComponentUIDAO.class);
|
||||
classes.add(IApplicationMappingUIDAO.class);
|
||||
classes.add(IApplicationReferenceMetricUIDAO.class);
|
||||
classes.add(ISegmentCostUIDAO.class);
|
||||
classes.add(ISegmentDurationUIDAO.class);
|
||||
classes.add(ISegmentUIDAO.class);
|
||||
classes.add(IServiceReferenceUIDAO.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
package org.apache.skywalking.apm.collector.storage.dao;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ISegmentCostPersistenceDAO<Insert, Update, DataImpl extends SegmentCost> extends IPersistenceDAO<Insert, Update, DataImpl> {
|
||||
public interface ISegmentDurationPersistenceDAO<Insert, Update, DataImpl extends SegmentDuration> extends IPersistenceDAO<Insert, Update, DataImpl> {
|
||||
}
|
||||
|
|
@ -18,22 +18,13 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.dao.ui;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ISegmentCostUIDAO extends DAO {
|
||||
JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName,
|
||||
Error error, int applicationId, List<String> segmentIds, int limit, int from, Sort sort);
|
||||
|
||||
enum Sort {
|
||||
Cost, Time
|
||||
}
|
||||
|
||||
enum Error {
|
||||
All, True, False
|
||||
}
|
||||
public interface ISegmentDurationUIDAO extends DAO {
|
||||
TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName,
|
||||
int applicationId, String traceId, int limit, int from);
|
||||
}
|
||||
|
|
@ -26,31 +26,32 @@ import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCost extends StreamData {
|
||||
public class SegmentDuration extends StreamData {
|
||||
|
||||
private static final Column[] STRING_COLUMNS = {
|
||||
new Column(SegmentCostTable.COLUMN_ID, new NonOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_SEGMENT_ID, new CoverOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_SERVICE_NAME, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_ID, new NonOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_SEGMENT_ID, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_SERVICE_NAME, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_TRACE_ID, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] LONG_COLUMNS = {
|
||||
new Column(SegmentCostTable.COLUMN_COST, new CoverOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_START_TIME, new CoverOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_END_TIME, new CoverOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_TIME_BUCKET, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_DURATION, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_START_TIME, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_END_TIME, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_TIME_BUCKET, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] DOUBLE_COLUMNS = {};
|
||||
|
||||
private static final Column[] INTEGER_COLUMNS = {
|
||||
new Column(SegmentCostTable.COLUMN_APPLICATION_ID, new CoverOperation()),
|
||||
new Column(SegmentCostTable.COLUMN_IS_ERROR, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_APPLICATION_ID, new CoverOperation()),
|
||||
new Column(SegmentDurationTable.COLUMN_IS_ERROR, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BYTE_COLUMNS = {};
|
||||
|
||||
public SegmentCost() {
|
||||
public SegmentDuration() {
|
||||
super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BYTE_COLUMNS);
|
||||
}
|
||||
|
||||
|
|
@ -86,12 +87,20 @@ public class SegmentCost extends StreamData {
|
|||
setDataString(2, serviceName);
|
||||
}
|
||||
|
||||
public Long getCost() {
|
||||
public String getTraceId() {
|
||||
return getDataString(3);
|
||||
}
|
||||
|
||||
public void setTraceId(String traceId) {
|
||||
setDataString(3, traceId);
|
||||
}
|
||||
|
||||
public Long getDuration() {
|
||||
return getDataLong(0);
|
||||
}
|
||||
|
||||
public void setCost(Long cost) {
|
||||
setDataLong(0, cost);
|
||||
public void setDuration(Long duration) {
|
||||
setDataLong(0, duration);
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.table.segment;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.data.CommonTable;
|
||||
|
|
@ -24,13 +23,14 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostTable extends CommonTable {
|
||||
public static final String TABLE = "segment_cost";
|
||||
public class SegmentDurationTable extends CommonTable {
|
||||
public static final String TABLE = "segment_duration";
|
||||
public static final String COLUMN_SEGMENT_ID = "segment_id";
|
||||
public static final String COLUMN_TRACE_ID = "trace_id";
|
||||
public static final String COLUMN_APPLICATION_ID = "application_id";
|
||||
public static final String COLUMN_START_TIME = "start_time";
|
||||
public static final String COLUMN_END_TIME = "end_time";
|
||||
public static final String COLUMN_SERVICE_NAME = "service_name";
|
||||
public static final String COLUMN_COST = "cost";
|
||||
public static final String COLUMN_DURATION = "duration";
|
||||
public static final String COLUMN_IS_ERROR = "is_error";
|
||||
}
|
||||
|
|
@ -24,4 +24,20 @@ package org.apache.skywalking.apm.collector.storage.ui.overview;
|
|||
public class ConjecturalApp {
|
||||
private String name;
|
||||
private int num;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(int num) {
|
||||
this.num = num;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,12 @@ import java.util.List;
|
|||
*/
|
||||
public class ConjecturalAppBrief {
|
||||
private List<ConjecturalApp> apps;
|
||||
|
||||
public List<ConjecturalApp> getApps() {
|
||||
return apps;
|
||||
}
|
||||
|
||||
public void setApps(List<ConjecturalApp> apps) {
|
||||
this.apps = apps;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,47 @@ package org.apache.skywalking.apm.collector.storage.ui.trace;
|
|||
public class BasicTrace {
|
||||
private String operationName;
|
||||
private int duration;
|
||||
private String start;
|
||||
private long start;
|
||||
private Boolean isError;
|
||||
private String traceId;
|
||||
|
||||
public String getOperationName() {
|
||||
return operationName;
|
||||
}
|
||||
|
||||
public void setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public long getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public Boolean getError() {
|
||||
return isError;
|
||||
}
|
||||
|
||||
public void setError(Boolean error) {
|
||||
isError = error;
|
||||
}
|
||||
|
||||
public String getTraceId() {
|
||||
return traceId;
|
||||
}
|
||||
|
||||
public void setTraceId(String traceId) {
|
||||
this.traceId = traceId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.ui.trace;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -25,5 +26,25 @@ import java.util.List;
|
|||
*/
|
||||
public class TraceBrief {
|
||||
private List<BasicTrace> traces;
|
||||
private Integer total;
|
||||
private int total;
|
||||
|
||||
public TraceBrief() {
|
||||
traces = new LinkedList<>();
|
||||
}
|
||||
|
||||
public List<BasicTrace> getTraces() {
|
||||
return traces;
|
||||
}
|
||||
|
||||
public void setTraces(List<BasicTrace> traces) {
|
||||
this.traces = traces;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public void setTotal(int total) {
|
||||
this.total = total;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,74 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.storage.ui.trace;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Duration;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Pagination;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class TraceQueryCondition {
|
||||
private List<String> applicationCodes;
|
||||
private int applicationId;
|
||||
private String traceId;
|
||||
private String operationName;
|
||||
private Duration queryDuration;
|
||||
private int minTraceDuration;
|
||||
private int maxTraceDuration;
|
||||
private Boolean topN;
|
||||
private int needTotal;
|
||||
private Pagination paging;
|
||||
|
||||
public int getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(int applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
public String getTraceId() {
|
||||
return traceId;
|
||||
}
|
||||
|
||||
public void setTraceId(String traceId) {
|
||||
this.traceId = traceId;
|
||||
}
|
||||
|
||||
public String getOperationName() {
|
||||
return operationName;
|
||||
}
|
||||
|
||||
public void setOperationName(String operationName) {
|
||||
this.operationName = operationName;
|
||||
}
|
||||
|
||||
public Duration getQueryDuration() {
|
||||
return queryDuration;
|
||||
}
|
||||
|
||||
public void setQueryDuration(Duration queryDuration) {
|
||||
this.queryDuration = queryDuration;
|
||||
}
|
||||
|
||||
public int getMinTraceDuration() {
|
||||
return minTraceDuration;
|
||||
}
|
||||
|
||||
public void setMinTraceDuration(int minTraceDuration) {
|
||||
this.minTraceDuration = minTraceDuration;
|
||||
}
|
||||
|
||||
public int getMaxTraceDuration() {
|
||||
return maxTraceDuration;
|
||||
}
|
||||
|
||||
public void setMaxTraceDuration(int maxTraceDuration) {
|
||||
this.maxTraceDuration = maxTraceDuration;
|
||||
}
|
||||
|
||||
public Pagination getPaging() {
|
||||
return paging;
|
||||
}
|
||||
|
||||
public void setPaging(Pagination paging) {
|
||||
this.paging = paging;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO;
|
||||
|
|
@ -113,8 +113,8 @@ public class DataTTLKeeperTimer {
|
|||
IApplicationReferenceMinuteMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class);
|
||||
applicationReferenceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
ISegmentCostPersistenceDAO segmentCostPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class);
|
||||
segmentCostPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
ISegmentDurationPersistenceDAO segmentDurationPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentDurationPersistenceDAO.class);
|
||||
segmentDurationPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
ISegmentPersistenceDAO segmentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentPersistenceDAO.class);
|
||||
segmentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule;
|
|||
import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO;
|
||||
|
|
@ -122,7 +122,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO;
|
||||
|
|
@ -130,7 +130,7 @@ import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO;
|
|||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.SegmentDurationEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentDayEsPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentHourEsPersistenceDAO;
|
||||
|
|
@ -219,7 +219,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceMetricEsUID
|
|||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryPoolMetricEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.NetworkAddressEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentCostEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO;
|
||||
|
|
@ -364,7 +364,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IApplicationReferenceDayMetricPersistenceDAO.class, new ApplicationReferenceDayMetricEsPersistenceDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationReferenceMonthMetricPersistenceDAO.class, new ApplicationReferenceMonthMetricEsPersistenceDAO(elasticSearchClient));
|
||||
|
||||
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentDurationPersistenceDAO.class, new SegmentDurationEsPersistenceDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient));
|
||||
|
||||
this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricEsPersistenceDAO(elasticSearchClient));
|
||||
|
|
@ -405,7 +405,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceEsUIDAO(elasticSearchClient));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.update.UpdateRequestBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
|
@ -36,46 +36,46 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostEsPersistenceDAO extends EsDAO implements ISegmentCostPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, SegmentCost> {
|
||||
public class SegmentDurationEsPersistenceDAO extends EsDAO implements ISegmentDurationPersistenceDAO<IndexRequestBuilder, UpdateRequestBuilder, SegmentDuration> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentCostEsPersistenceDAO.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentDurationEsPersistenceDAO.class);
|
||||
|
||||
public SegmentCostEsPersistenceDAO(ElasticSearchClient client) {
|
||||
public SegmentDurationEsPersistenceDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public SegmentCost get(String id) {
|
||||
@Override public SegmentDuration get(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public UpdateRequestBuilder prepareBatchUpdate(SegmentCost data) {
|
||||
@Override public UpdateRequestBuilder prepareBatchUpdate(SegmentDuration data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public IndexRequestBuilder prepareBatchInsert(SegmentCost data) {
|
||||
@Override public IndexRequestBuilder prepareBatchInsert(SegmentDuration data) {
|
||||
logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId());
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(SegmentCostTable.COLUMN_SEGMENT_ID, data.getSegmentId());
|
||||
source.put(SegmentCostTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(SegmentCostTable.COLUMN_SERVICE_NAME, data.getServiceName());
|
||||
source.put(SegmentCostTable.COLUMN_COST, data.getCost());
|
||||
source.put(SegmentCostTable.COLUMN_START_TIME, data.getStartTime());
|
||||
source.put(SegmentCostTable.COLUMN_END_TIME, data.getEndTime());
|
||||
source.put(SegmentCostTable.COLUMN_IS_ERROR, data.getIsError());
|
||||
source.put(SegmentCostTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
source.put(SegmentDurationTable.COLUMN_SEGMENT_ID, data.getSegmentId());
|
||||
source.put(SegmentDurationTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(SegmentDurationTable.COLUMN_SERVICE_NAME, data.getServiceName());
|
||||
source.put(SegmentDurationTable.COLUMN_DURATION, data.getDuration());
|
||||
source.put(SegmentDurationTable.COLUMN_START_TIME, data.getStartTime());
|
||||
source.put(SegmentDurationTable.COLUMN_END_TIME, data.getEndTime());
|
||||
source.put(SegmentDurationTable.COLUMN_IS_ERROR, data.getIsError());
|
||||
source.put(SegmentDurationTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
logger.debug("segment cost source: {}", source.toString());
|
||||
return getClient().prepareIndex(SegmentCostTable.TABLE, data.getId()).setSource(source);
|
||||
return getClient().prepareIndex(SegmentDurationTable.TABLE, data.getId()).setSource(source);
|
||||
}
|
||||
|
||||
@Override public void deleteHistory(Long startTimestamp, Long endTimestamp) {
|
||||
long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp);
|
||||
long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp);
|
||||
BulkByScrollResponse response = getClient().prepareDelete()
|
||||
.filter(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket))
|
||||
.source(SegmentCostTable.TABLE)
|
||||
.filter(QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket))
|
||||
.source(SegmentDurationTable.TABLE)
|
||||
.get();
|
||||
|
||||
long deleted = response.getDeleted();
|
||||
logger.info("Delete {} rows history from {} index.", deleted, SegmentCostTable.TABLE);
|
||||
logger.info("Delete {} rows history from {} index.", deleted, SegmentDurationTable.TABLE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.CollectionUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.RangeQueryBuilder;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostEsUIDAO extends EsDAO implements ISegmentCostUIDAO {
|
||||
|
||||
public SegmentCostEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName,
|
||||
Error error, int applicationId, List<String> segmentIds, int limit, int from, Sort sort) {
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentCostTable.TABLE);
|
||||
searchRequestBuilder.setTypes(SegmentCostTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
searchRequestBuilder.setQuery(boolQueryBuilder);
|
||||
List<QueryBuilder> mustQueryList = boolQueryBuilder.must();
|
||||
|
||||
mustQueryList.add(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
if (minCost != -1 || maxCost != -1) {
|
||||
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_COST);
|
||||
if (minCost != -1) {
|
||||
rangeQueryBuilder.gte(minCost);
|
||||
}
|
||||
if (maxCost != -1) {
|
||||
rangeQueryBuilder.lte(maxCost);
|
||||
}
|
||||
boolQueryBuilder.must().add(rangeQueryBuilder);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
mustQueryList.add(QueryBuilders.matchQuery(SegmentCostTable.COLUMN_SERVICE_NAME, operationName));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(segmentIds)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termsQuery(SegmentCostTable.COLUMN_SEGMENT_ID, segmentIds.toArray(new String[0])));
|
||||
}
|
||||
if (Error.True.equals(error)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, true));
|
||||
} else if (Error.False.equals(error)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, false));
|
||||
}
|
||||
if (applicationId != 0) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
}
|
||||
|
||||
if (Sort.Cost.equals(sort)) {
|
||||
searchRequestBuilder.addSort(SegmentCostTable.COLUMN_COST, SortOrder.DESC);
|
||||
} else if (Sort.Time.equals(sort)) {
|
||||
searchRequestBuilder.addSort(SegmentCostTable.COLUMN_START_TIME, SortOrder.DESC);
|
||||
}
|
||||
searchRequestBuilder.setSize(limit);
|
||||
searchRequestBuilder.setFrom(from);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
JsonObject topSegPaging = new JsonObject();
|
||||
topSegPaging.addProperty("recordsTotal", searchResponse.getHits().totalHits);
|
||||
|
||||
JsonArray topSegArray = new JsonArray();
|
||||
topSegPaging.add("data", topSegArray);
|
||||
|
||||
int num = from;
|
||||
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
|
||||
JsonObject topSegmentJson = new JsonObject();
|
||||
topSegmentJson.addProperty("num", num);
|
||||
String segmentId = (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SEGMENT_ID);
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId);
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_START_TIME));
|
||||
if (searchHit.getSource().containsKey(SegmentCostTable.COLUMN_END_TIME)) {
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME));
|
||||
}
|
||||
|
||||
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));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, (Boolean)searchHit.getSource().get(SegmentCostTable.COLUMN_IS_ERROR));
|
||||
|
||||
num++;
|
||||
topSegArray.add(topSegmentJson);
|
||||
}
|
||||
|
||||
return topSegPaging;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.dao.ui;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.BasicTrace;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
|
||||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.RangeQueryBuilder;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUIDAO {
|
||||
|
||||
public SegmentDurationEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName,
|
||||
int applicationId, String traceId, int limit, int from) {
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentDurationTable.TABLE);
|
||||
searchRequestBuilder.setTypes(SegmentDurationTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
searchRequestBuilder.setQuery(boolQueryBuilder);
|
||||
List<QueryBuilder> mustQueryList = boolQueryBuilder.must();
|
||||
|
||||
mustQueryList.add(QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime));
|
||||
if (minDuration != 0 || maxDuration != 0) {
|
||||
RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_DURATION);
|
||||
if (minDuration != 0) {
|
||||
rangeQueryBuilder.gte(minDuration);
|
||||
}
|
||||
if (maxDuration != 0) {
|
||||
rangeQueryBuilder.lte(maxDuration);
|
||||
}
|
||||
boolQueryBuilder.must().add(rangeQueryBuilder);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
mustQueryList.add(QueryBuilders.matchQuery(SegmentDurationTable.COLUMN_SERVICE_NAME, operationName));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentDurationTable.COLUMN_SEGMENT_ID, traceId));
|
||||
}
|
||||
if (applicationId != 0) {
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentDurationTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
}
|
||||
|
||||
searchRequestBuilder.setSize(limit);
|
||||
searchRequestBuilder.setFrom(from);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
TraceBrief traceBrief = new TraceBrief();
|
||||
traceBrief.setTotal((int)searchResponse.getHits().totalHits);
|
||||
|
||||
for (SearchHit searchHit : searchResponse.getHits().getHits()) {
|
||||
BasicTrace basicTrace = new BasicTrace();
|
||||
|
||||
basicTrace.setTraceId((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_TRACE_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());
|
||||
basicTrace.setError(BooleanUtils.valueToBoolean(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_IS_ERROR)).intValue()));
|
||||
traceBrief.getTraces().add(basicTrace);
|
||||
}
|
||||
|
||||
return traceBrief;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostEsTableDefine extends ElasticSearchTableDefine {
|
||||
|
||||
public SegmentCostEsTableDefine() {
|
||||
super(SegmentCostTable.TABLE);
|
||||
}
|
||||
|
||||
@Override public int refreshInterval() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override public void initialize() {
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_SEGMENT_ID, ElasticSearchColumnDefine.Type.Keyword.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_COST, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_START_TIME, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_END_TIME, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentDurationEsTableDefine extends ElasticSearchTableDefine {
|
||||
|
||||
public SegmentDurationEsTableDefine() {
|
||||
super(SegmentDurationTable.TABLE);
|
||||
}
|
||||
|
||||
@Override public int refreshInterval() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override public void initialize() {
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_SEGMENT_ID, ElasticSearchColumnDefine.Type.Keyword.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_TRACE_ID, ElasticSearchColumnDefine.Type.Keyword.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_DURATION, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_START_TIME, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_END_TIME, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_IS_ERROR, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationMonthMetric
|
|||
|
||||
org.apache.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine
|
||||
org.apache.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine
|
||||
org.apache.skywalking.apm.collector.storage.es.define.SegmentCostEsTableDefine
|
||||
org.apache.skywalking.apm.collector.storage.es.define.SegmentDurationEsTableDefine
|
||||
|
||||
org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmEsTableDefine
|
||||
org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListEsTableDefine
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule;
|
|||
import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO;
|
||||
|
|
@ -118,7 +118,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO;
|
|||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO;
|
||||
|
|
@ -126,7 +126,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO;
|
|||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentDurationH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentDayH2PersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentHourH2PersistenceDAO;
|
||||
|
|
@ -215,7 +215,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceMetricH2UID
|
|||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryPoolMetricH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.NetworkAddressH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentCostH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO;
|
||||
|
|
@ -316,7 +316,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IMemoryPoolMonthMetricPersistenceDAO.class, new MemoryPoolMonthMetricH2PersistenceDAO(h2Client));
|
||||
|
||||
this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentDurationPersistenceDAO.class, new SegmentDurationH2PersistenceDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client));
|
||||
this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client));
|
||||
|
||||
|
|
@ -381,7 +381,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceH2UIDAO(h2Client));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,51 +23,51 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng, clevertension
|
||||
*/
|
||||
public class SegmentCostH2PersistenceDAO extends H2DAO implements ISegmentCostPersistenceDAO<H2SqlEntity, H2SqlEntity, SegmentCost> {
|
||||
public class SegmentDurationH2PersistenceDAO extends H2DAO implements ISegmentDurationPersistenceDAO<H2SqlEntity, H2SqlEntity, SegmentDuration> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentCostH2PersistenceDAO.class);
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentDurationH2PersistenceDAO.class);
|
||||
|
||||
public SegmentCostH2PersistenceDAO(H2Client client) {
|
||||
public SegmentDurationH2PersistenceDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public SegmentCost get(String id) {
|
||||
@Override public SegmentDuration get(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public H2SqlEntity prepareBatchInsert(SegmentCost data) {
|
||||
@Override public H2SqlEntity prepareBatchInsert(SegmentDuration data) {
|
||||
logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId());
|
||||
H2SqlEntity entity = new H2SqlEntity();
|
||||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(SegmentCostTable.COLUMN_ID, data.getId());
|
||||
source.put(SegmentCostTable.COLUMN_SEGMENT_ID, data.getSegmentId());
|
||||
source.put(SegmentCostTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(SegmentCostTable.COLUMN_SERVICE_NAME, data.getServiceName());
|
||||
source.put(SegmentCostTable.COLUMN_COST, data.getCost());
|
||||
source.put(SegmentCostTable.COLUMN_START_TIME, data.getStartTime());
|
||||
source.put(SegmentCostTable.COLUMN_END_TIME, data.getEndTime());
|
||||
source.put(SegmentCostTable.COLUMN_IS_ERROR, data.getIsError());
|
||||
source.put(SegmentCostTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
source.put(SegmentDurationTable.COLUMN_ID, data.getId());
|
||||
source.put(SegmentDurationTable.COLUMN_SEGMENT_ID, data.getSegmentId());
|
||||
source.put(SegmentDurationTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(SegmentDurationTable.COLUMN_SERVICE_NAME, data.getServiceName());
|
||||
source.put(SegmentDurationTable.COLUMN_DURATION, data.getDuration());
|
||||
source.put(SegmentDurationTable.COLUMN_START_TIME, data.getStartTime());
|
||||
source.put(SegmentDurationTable.COLUMN_END_TIME, data.getEndTime());
|
||||
source.put(SegmentDurationTable.COLUMN_IS_ERROR, data.getIsError());
|
||||
source.put(SegmentDurationTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
logger.debug("segment cost source: {}", source.toString());
|
||||
|
||||
String sql = SqlBuilder.buildBatchInsertSql(SegmentCostTable.TABLE, source.keySet());
|
||||
String sql = SqlBuilder.buildBatchInsertSql(SegmentDurationTable.TABLE, source.keySet());
|
||||
entity.setSql(sql);
|
||||
entity.setParams(source.values().toArray(new Object[0]));
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override public H2SqlEntity prepareBatchUpdate(SegmentCost data) {
|
||||
@Override public H2SqlEntity prepareBatchUpdate(SegmentDuration data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.core.util.CollectionUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng, clevertension
|
||||
*/
|
||||
public class SegmentCostH2UIDAO extends H2DAO implements ISegmentCostUIDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentCostH2UIDAO.class);
|
||||
private static final String GET_SEGMENT_COST_SQL = "select * from {0} where {1} >= ? and {1} <= ?";
|
||||
|
||||
public SegmentCostH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName,
|
||||
Error error, int applicationId, List<String> segmentIds, int limit, int from, Sort sort) {
|
||||
H2Client client = getClient();
|
||||
String sql = GET_SEGMENT_COST_SQL;
|
||||
List<Object> params = new ArrayList<>();
|
||||
List<Object> columns = new ArrayList<>();
|
||||
columns.add(SegmentCostTable.TABLE);
|
||||
columns.add(SegmentCostTable.COLUMN_TIME_BUCKET);
|
||||
params.add(startTime);
|
||||
params.add(endTime);
|
||||
int paramIndex = 1;
|
||||
if (minCost != -1 || maxCost != -1) {
|
||||
if (minCost != -1) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} >= ?";
|
||||
params.add(minCost);
|
||||
columns.add(SegmentCostTable.COLUMN_COST);
|
||||
}
|
||||
if (maxCost != -1) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} <= ?";
|
||||
params.add(maxCost);
|
||||
columns.add(SegmentCostTable.COLUMN_COST);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(operationName);
|
||||
columns.add(SegmentCostTable.COLUMN_SERVICE_NAME);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(segmentIds)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} in (";
|
||||
columns.add(SegmentCostTable.COLUMN_SEGMENT_ID);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < segmentIds.size(); i++) {
|
||||
builder.append("?,");
|
||||
}
|
||||
builder.delete(builder.length() - 1, builder.length());
|
||||
builder.append(")");
|
||||
sql = sql + builder;
|
||||
for (String segmentId : segmentIds) {
|
||||
params.add(segmentId);
|
||||
}
|
||||
}
|
||||
if (Error.True.equals(error)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(true);
|
||||
columns.add(SegmentCostTable.COLUMN_IS_ERROR);
|
||||
} else if (Error.False.equals(error)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(false);
|
||||
columns.add(SegmentCostTable.COLUMN_IS_ERROR);
|
||||
}
|
||||
if (applicationId != 0) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(applicationId);
|
||||
columns.add(SegmentCostTable.COLUMN_APPLICATION_ID);
|
||||
}
|
||||
|
||||
if (Sort.Cost.equals(sort)) {
|
||||
sql = sql + " order by " + SegmentCostTable.COLUMN_COST + " " + SortOrder.DESC;
|
||||
} else if (Sort.Time.equals(sort)) {
|
||||
sql = sql + " order by " + SegmentCostTable.COLUMN_START_TIME + " " + SortOrder.DESC;
|
||||
}
|
||||
|
||||
sql = sql + " limit " + from + "," + limit;
|
||||
sql = SqlBuilder.buildSql(sql, columns);
|
||||
Object[] p = params.toArray(new Object[0]);
|
||||
|
||||
JsonObject topSegPaging = new JsonObject();
|
||||
|
||||
JsonArray topSegArray = new JsonArray();
|
||||
topSegPaging.add("data", topSegArray);
|
||||
int cnt = 0;
|
||||
int num = from;
|
||||
try (ResultSet rs = client.executeQuery(sql, p)) {
|
||||
while (rs.next()) {
|
||||
JsonObject topSegmentJson = new JsonObject();
|
||||
topSegmentJson.addProperty("num", num);
|
||||
String segmentId = rs.getString(SegmentCostTable.COLUMN_SEGMENT_ID);
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId);
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, rs.getLong(SegmentCostTable.COLUMN_START_TIME));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, rs.getLong(SegmentCostTable.COLUMN_END_TIME));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, rs.getInt(SegmentCostTable.COLUMN_APPLICATION_ID));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, rs.getString(SegmentCostTable.COLUMN_SERVICE_NAME));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, rs.getLong(SegmentCostTable.COLUMN_COST));
|
||||
topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, rs.getBoolean(SegmentCostTable.COLUMN_IS_ERROR));
|
||||
|
||||
num++;
|
||||
topSegArray.add(topSegmentJson);
|
||||
cnt++;
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
topSegPaging.addProperty("recordsTotal", cnt);
|
||||
return topSegPaging;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao.ui;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.apache.skywalking.apm.collector.core.util.BooleanUtils;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.BasicTrace;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng, clevertension
|
||||
*/
|
||||
public class SegmentDurationH2UIDAO extends H2DAO implements ISegmentDurationUIDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentDurationH2UIDAO.class);
|
||||
|
||||
public SegmentDurationH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName,
|
||||
int applicationId, String traceId, int limit, int from) {
|
||||
H2Client client = getClient();
|
||||
String sql = "select * from {0} where {1} >= ? and {1} <= ?";
|
||||
List<Object> params = new ArrayList<>();
|
||||
List<Object> columns = new ArrayList<>();
|
||||
columns.add(SegmentDurationTable.TABLE);
|
||||
columns.add(SegmentDurationTable.COLUMN_TIME_BUCKET);
|
||||
params.add(startTime);
|
||||
params.add(endTime);
|
||||
int paramIndex = 1;
|
||||
if (minDuration != -1 || maxDuration != -1) {
|
||||
if (minDuration != -1) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} >= ?";
|
||||
params.add(minDuration);
|
||||
columns.add(SegmentDurationTable.COLUMN_DURATION);
|
||||
}
|
||||
if (maxDuration != -1) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} <= ?";
|
||||
params.add(maxDuration);
|
||||
columns.add(SegmentDurationTable.COLUMN_DURATION);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(operationName)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(operationName);
|
||||
columns.add(SegmentDurationTable.COLUMN_SERVICE_NAME);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(traceId)) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(traceId);
|
||||
columns.add(SegmentDurationTable.COLUMN_TRACE_ID);
|
||||
}
|
||||
if (applicationId != 0) {
|
||||
paramIndex++;
|
||||
sql = sql + " and {" + paramIndex + "} = ?";
|
||||
params.add(applicationId);
|
||||
columns.add(SegmentDurationTable.COLUMN_APPLICATION_ID);
|
||||
}
|
||||
|
||||
sql = sql + " limit " + from + "," + limit;
|
||||
sql = SqlBuilder.buildSql(sql, columns);
|
||||
Object[] p = params.toArray(new Object[0]);
|
||||
|
||||
TraceBrief traceBrief = new TraceBrief();
|
||||
|
||||
int cnt = 0;
|
||||
try (ResultSet rs = client.executeQuery(sql, p)) {
|
||||
while (rs.next()) {
|
||||
BasicTrace basicTrace = new BasicTrace();
|
||||
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);
|
||||
cnt++;
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
traceBrief.setTotal(cnt);
|
||||
return traceBrief;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentCostH2TableDefine extends H2TableDefine {
|
||||
|
||||
public SegmentCostH2TableDefine() {
|
||||
super(SegmentCostTable.TABLE);
|
||||
}
|
||||
|
||||
@Override public void initialize() {
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_SEGMENT_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_COST, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_START_TIME, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_END_TIME, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentDurationH2TableDefine extends H2TableDefine {
|
||||
|
||||
public SegmentDurationH2TableDefine() {
|
||||
super(SegmentDurationTable.TABLE);
|
||||
}
|
||||
|
||||
@Override public void initialize() {
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_SEGMENT_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_TRACE_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_DURATION, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_START_TIME, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_END_TIME, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ org.apache.skywalking.apm.collector.storage.h2.define.instmapping.InstanceMappin
|
|||
org.apache.skywalking.apm.collector.storage.h2.define.instmapping.InstanceMappingMonthH2TableDefine
|
||||
|
||||
org.apache.skywalking.apm.collector.storage.h2.define.GlobalTraceH2TableDefine
|
||||
org.apache.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine
|
||||
org.apache.skywalking.apm.collector.storage.h2.define.SegmentDurationH2TableDefine
|
||||
org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine
|
||||
|
||||
org.apache.skywalking.apm.collector.storage.h2.define.amp.ApplicationMinuteMetricH2TableDefine
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBri
|
|||
import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo;
|
||||
import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
||||
import org.apache.skywalking.apm.collector.ui.service.AlarmService;
|
||||
import org.apache.skywalking.apm.collector.ui.service.ApplicationService;
|
||||
import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService;
|
||||
import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService;
|
||||
|
|
@ -46,6 +47,7 @@ public class OverViewLayerQuery implements Query {
|
|||
private ApplicationService applicationService;
|
||||
private NetworkAddressService networkAddressService;
|
||||
private ServiceNameService serviceNameService;
|
||||
private AlarmService alarmService;
|
||||
|
||||
public OverViewLayerQuery(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
|
|
@ -79,6 +81,13 @@ public class OverViewLayerQuery implements Query {
|
|||
return serviceNameService;
|
||||
}
|
||||
|
||||
private AlarmService getAlarmService() {
|
||||
if (ObjectUtils.isEmpty(alarmService)) {
|
||||
this.alarmService = new AlarmService(moduleManager);
|
||||
}
|
||||
return alarmService;
|
||||
}
|
||||
|
||||
public Topology getClusterTopology(Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
|
|
@ -99,8 +108,10 @@ public class OverViewLayerQuery implements Query {
|
|||
return clusterBrief;
|
||||
}
|
||||
|
||||
public AlarmTrend getAlarmTrend(Duration duration) {
|
||||
return null;
|
||||
public AlarmTrend getAlarmTrend(Duration duration) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd());
|
||||
return getAlarmService().getApplicationAlarmTrend(duration.getStep(), start, end);
|
||||
}
|
||||
|
||||
public ConjecturalAppBrief getConjecturalApps(Duration duration) {
|
||||
|
|
|
|||
|
|
@ -18,17 +18,48 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.ui.query;
|
||||
|
||||
import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
||||
import java.text.ParseException;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.Trace;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceQueryCondition;
|
||||
import org.apache.skywalking.apm.collector.ui.graphql.Query;
|
||||
import org.apache.skywalking.apm.collector.ui.service.SegmentTopService;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class TraceQuery implements Query {
|
||||
public TraceBrief queryBasicTraces(TraceQueryCondition condition) {
|
||||
return null;
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private SegmentTopService segmentTopService;
|
||||
|
||||
public TraceQuery(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
}
|
||||
|
||||
private SegmentTopService getSegmentTopService() {
|
||||
if (ObjectUtils.isEmpty(segmentTopService)) {
|
||||
this.segmentTopService = new SegmentTopService(moduleManager);
|
||||
}
|
||||
return segmentTopService;
|
||||
}
|
||||
|
||||
public TraceBrief queryBasicTraces(TraceQueryCondition condition) throws ParseException {
|
||||
long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart());
|
||||
long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getEnd());
|
||||
|
||||
long minDuration = condition.getMinTraceDuration();
|
||||
long maxDuration = condition.getMaxTraceDuration();
|
||||
String operationName = condition.getOperationName();
|
||||
String traceId = condition.getTraceId();
|
||||
int applicationId = condition.getApplicationId();
|
||||
int limit = condition.getPaging().getPageSize();
|
||||
int from = condition.getPaging().getPageSize() * condition.getPaging().getPageNum();
|
||||
|
||||
return segmentTopService.loadTop(start, end, minDuration, maxDuration, operationName, traceId, applicationId, limit, from);
|
||||
}
|
||||
|
||||
public Trace queryTrace(String id) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.ui.service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.common.Step;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend;
|
||||
import org.apache.skywalking.apm.collector.storage.utils.DurationPoint;
|
||||
import org.apache.skywalking.apm.collector.ui.utils.DurationUtils;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class AlarmService {
|
||||
|
||||
public AlarmService(ModuleManager moduleManager) {
|
||||
|
||||
}
|
||||
|
||||
public AlarmTrend getApplicationAlarmTrend(Step step, long start, long end) throws ParseException {
|
||||
List<DurationPoint> durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end);
|
||||
|
||||
AlarmTrend alarmTrend = new AlarmTrend();
|
||||
return alarmTrend;
|
||||
}
|
||||
}
|
||||
|
|
@ -16,22 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.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.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.CollectionUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable;
|
||||
import org.apache.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -42,34 +32,16 @@ public class SegmentTopService {
|
|||
|
||||
private final Logger logger = LoggerFactory.getLogger(SegmentTopService.class);
|
||||
|
||||
private final IGlobalTraceUIDAO globalTraceDAO;
|
||||
private final ISegmentCostUIDAO segmentCostDAO;
|
||||
private final ISegmentDurationUIDAO segmentDurationUIDAO;
|
||||
|
||||
public SegmentTopService(ModuleManager moduleManager) {
|
||||
this.globalTraceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTraceUIDAO.class);
|
||||
this.segmentCostDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostUIDAO.class);
|
||||
this.segmentDurationUIDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentDurationUIDAO.class);
|
||||
}
|
||||
|
||||
public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName,
|
||||
String globalTraceId, ISegmentCostUIDAO.Error error, int applicationId, int limit, int from,
|
||||
ISegmentCostUIDAO.Sort sort) {
|
||||
logger.debug("startTime: {}, endTime: {}, minCost: {}, maxCost: {}, operationName: {}, globalTraceId: {}, error: {}, applicationId: {}, limit: {}, from: {}", startTime, endTime, minCost, maxCost, operationName, globalTraceId, error, applicationId, limit, from);
|
||||
public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName,
|
||||
String traceId, int applicationId, int limit, int from) {
|
||||
logger.debug("startTime: {}, endTime: {}, minDuration: {}, maxDuration: {}, operationName: {}, traceId: {}, applicationId: {}, limit: {}, from: {}", startTime, endTime, minDuration, maxDuration, operationName, traceId, applicationId, limit, from);
|
||||
|
||||
List<String> segmentIds = new LinkedList<>();
|
||||
if (StringUtils.isNotEmpty(globalTraceId)) {
|
||||
segmentIds = globalTraceDAO.getSegmentIds(globalTraceId);
|
||||
}
|
||||
|
||||
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;
|
||||
return segmentDurationUIDAO.loadTop(startTime, endTime, minDuration, maxDuration, operationName, applicationId, traceId, limit, from);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ type BasicTrace {
|
|||
|
||||
# Represent the conditions used for query TraceBrief
|
||||
input TraceQueryCondition {
|
||||
applicationCodes: [String!]
|
||||
# The value of 0 means all application.
|
||||
applicationId: Int
|
||||
traceId: String
|
||||
operationName: String
|
||||
# The time range of traces started
|
||||
|
|
|
|||
Loading…
Reference in New Issue