Change the instance performance entity to instance metric entity.
This commit is contained in:
parent
119837a835
commit
be37792eda
|
|
@ -69,8 +69,8 @@ public class AgentStreamBootStartup {
|
|||
traceStreamGraph.createSegmentStandardizationGraph();
|
||||
traceStreamGraph.createGlobalTraceGraph();
|
||||
traceStreamGraph.createInstanceMetricGraph();
|
||||
traceStreamGraph.createNodeComponentGraph();
|
||||
traceStreamGraph.createNodeMappingGraph();
|
||||
traceStreamGraph.createApplicationComponentGraph();
|
||||
traceStreamGraph.createApplicationMappingGraph();
|
||||
traceStreamGraph.createApplicationReferenceMetricGraph();
|
||||
traceStreamGraph.createServiceEntryGraph();
|
||||
traceStreamGraph.createServiceReferenceGraph();
|
||||
|
|
|
|||
|
|
@ -20,17 +20,17 @@ package org.skywalking.apm.collector.agent.stream.graph;
|
|||
|
||||
import org.skywalking.apm.collector.agent.stream.parser.standardization.SegmentStandardization;
|
||||
import org.skywalking.apm.collector.agent.stream.parser.standardization.SegmentStandardizationWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricAggregationWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricRemoteWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.global.GlobalTracePersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.instance.InstanceMetricPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationComponentAggregationWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationComponentPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationComponentRemoteWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationMappingAggregationWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationMappingPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationMappingRemoteWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricAggregationWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.application.ApplicationReferenceMetricRemoteWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.global.GlobalTracePersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.instance.InstanceMetricPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.segment.SegmentCostPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.segment.SegmentPersistenceWorker;
|
||||
import org.skywalking.apm.collector.agent.stream.worker.trace.service.ServiceEntryAggregationWorker;
|
||||
|
|
@ -46,11 +46,11 @@ import org.skywalking.apm.collector.queue.QueueModule;
|
|||
import org.skywalking.apm.collector.queue.service.QueueCreatorService;
|
||||
import org.skywalking.apm.collector.remote.RemoteModule;
|
||||
import org.skywalking.apm.collector.remote.service.RemoteSenderService;
|
||||
import org.skywalking.apm.collector.storage.table.global.GlobalTrace;
|
||||
import org.skywalking.apm.collector.storage.table.instance.InstanceMetric;
|
||||
import org.skywalking.apm.collector.storage.table.application.ApplicationComponent;
|
||||
import org.skywalking.apm.collector.storage.table.application.ApplicationMapping;
|
||||
import org.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric;
|
||||
import org.skywalking.apm.collector.storage.table.global.GlobalTrace;
|
||||
import org.skywalking.apm.collector.storage.table.instance.InstanceMetric;
|
||||
import org.skywalking.apm.collector.storage.table.segment.Segment;
|
||||
import org.skywalking.apm.collector.storage.table.segment.SegmentCost;
|
||||
import org.skywalking.apm.collector.storage.table.service.ServiceEntry;
|
||||
|
|
@ -64,8 +64,8 @@ public class TraceStreamGraph {
|
|||
|
||||
public static final int GLOBAL_TRACE_GRAPH_ID = 300;
|
||||
public static final int INSTANCE_METRIC_GRAPH_ID = 301;
|
||||
public static final int NODE_COMPONENT_GRAPH_ID = 302;
|
||||
public static final int NODE_MAPPING_GRAPH_ID = 303;
|
||||
public static final int APPLICATION_COMPONENT_GRAPH_ID = 302;
|
||||
public static final int APPLICATION_MAPPING_GRAPH_ID = 303;
|
||||
public static final int APPLICATION_REFERENCE_METRIC_GRAPH_ID = 304;
|
||||
public static final int SERVICE_ENTRY_GRAPH_ID = 305;
|
||||
public static final int SERVICE_REFERENCE_GRAPH_ID = 306;
|
||||
|
|
@ -106,24 +106,24 @@ public class TraceStreamGraph {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createNodeComponentGraph() {
|
||||
public void createApplicationComponentGraph() {
|
||||
QueueCreatorService<ApplicationComponent> queueCreatorService = moduleManager.find(QueueModule.NAME).getService(QueueCreatorService.class);
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ApplicationComponent> graph = GraphManager.INSTANCE.createIfAbsent(NODE_COMPONENT_GRAPH_ID, ApplicationComponent.class);
|
||||
Graph<ApplicationComponent> graph = GraphManager.INSTANCE.createIfAbsent(APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class);
|
||||
graph.addNode(new ApplicationComponentAggregationWorker.Factory(moduleManager, queueCreatorService).create(workerCreateListener))
|
||||
.addNext(new ApplicationComponentRemoteWorker.Factory(moduleManager, remoteSenderService, NODE_COMPONENT_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationComponentRemoteWorker.Factory(moduleManager, remoteSenderService, APPLICATION_COMPONENT_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationComponentPersistenceWorker.Factory(moduleManager, queueCreatorService).create(workerCreateListener));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void createNodeMappingGraph() {
|
||||
public void createApplicationMappingGraph() {
|
||||
QueueCreatorService<ApplicationMapping> queueCreatorService = moduleManager.find(QueueModule.NAME).getService(QueueCreatorService.class);
|
||||
RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class);
|
||||
|
||||
Graph<ApplicationMapping> graph = GraphManager.INSTANCE.createIfAbsent(NODE_MAPPING_GRAPH_ID, ApplicationMapping.class);
|
||||
Graph<ApplicationMapping> graph = GraphManager.INSTANCE.createIfAbsent(APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class);
|
||||
graph.addNode(new ApplicationMappingAggregationWorker.Factory(moduleManager, queueCreatorService).create(workerCreateListener))
|
||||
.addNext(new ApplicationMappingRemoteWorker.Factory(moduleManager, remoteSenderService, NODE_MAPPING_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationMappingRemoteWorker.Factory(moduleManager, remoteSenderService, APPLICATION_MAPPING_GRAPH_ID).create(workerCreateListener))
|
||||
.addNext(new ApplicationMappingPersistenceWorker.Factory(moduleManager, queueCreatorService).create(workerCreateListener));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit
|
|||
}
|
||||
|
||||
@Override public void build() {
|
||||
Graph<ApplicationComponent> graph = GraphManager.INSTANCE.createIfAbsent(TraceStreamGraph.NODE_COMPONENT_GRAPH_ID, ApplicationComponent.class);
|
||||
Graph<ApplicationComponent> graph = GraphManager.INSTANCE.createIfAbsent(TraceStreamGraph.APPLICATION_COMPONENT_GRAPH_ID, ApplicationComponent.class);
|
||||
|
||||
applicationComponents.forEach(nodeComponent -> {
|
||||
nodeComponent.setId(timeBucket + Const.ID_SPLIT + nodeComponent.getId());
|
||||
nodeComponent.setTimeBucket(timeBucket);
|
||||
graph.start(nodeComponent);
|
||||
applicationComponents.forEach(applicationComponent -> {
|
||||
applicationComponent.setId(timeBucket + Const.ID_SPLIT + applicationComponent.getId());
|
||||
applicationComponent.setTimeBucket(timeBucket);
|
||||
graph.start(applicationComponent);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ApplicationMappingSpanListener implements RefsListener, FirstSpanLi
|
|||
|
||||
@Override public void build() {
|
||||
logger.debug("node mapping listener build");
|
||||
Graph<ApplicationMapping> graph = GraphManager.INSTANCE.createIfAbsent(TraceStreamGraph.NODE_MAPPING_GRAPH_ID, ApplicationMapping.class);
|
||||
Graph<ApplicationMapping> graph = GraphManager.INSTANCE.createIfAbsent(TraceStreamGraph.APPLICATION_MAPPING_GRAPH_ID, ApplicationMapping.class);
|
||||
|
||||
for (ApplicationMapping applicationMapping : applicationMappings) {
|
||||
applicationMapping.setId(timeBucket + Const.ID_SPLIT + applicationMapping.getId());
|
||||
|
|
|
|||
|
|
@ -71,20 +71,20 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
|
|||
Const.ID_SPLIT + spanDecorator.getPeerId();
|
||||
|
||||
applicationReferenceMetric.setId(idBuilder);
|
||||
applicationReferenceMetrics.add(buildNodeRefSum(applicationReferenceMetric, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
applicationReferenceMetrics.add(buildApplicationRefSum(applicationReferenceMetric, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId,
|
||||
String segmentId) {
|
||||
if (CollectionUtils.isNotEmpty(references)) {
|
||||
references.forEach(nodeReference -> {
|
||||
nodeReference.setTimeBucket(TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()));
|
||||
String idBuilder = String.valueOf(nodeReference.getTimeBucket()) + Const.ID_SPLIT + nodeReference.getFrontApplicationId() +
|
||||
Const.ID_SPLIT + nodeReference.getBehindApplicationId();
|
||||
references.forEach(applicationReference -> {
|
||||
applicationReference.setTimeBucket(TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()));
|
||||
String idBuilder = String.valueOf(applicationReference.getTimeBucket()) + Const.ID_SPLIT + applicationReference.getFrontApplicationId() +
|
||||
Const.ID_SPLIT + applicationReference.getBehindApplicationId();
|
||||
|
||||
nodeReference.setId(idBuilder);
|
||||
applicationReferenceMetrics.add(buildNodeRefSum(nodeReference, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
applicationReference.setId(idBuilder);
|
||||
applicationReferenceMetrics.add(buildApplicationRefSum(applicationReference, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
});
|
||||
} else {
|
||||
ApplicationReferenceMetric applicationReferenceMetric = new ApplicationReferenceMetric(Const.EMPTY_STRING);
|
||||
|
|
@ -96,7 +96,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
|
|||
Const.ID_SPLIT + applicationReferenceMetric.getBehindApplicationId();
|
||||
|
||||
applicationReferenceMetric.setId(idBuilder);
|
||||
applicationReferenceMetrics.add(buildNodeRefSum(applicationReferenceMetric, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
applicationReferenceMetrics.add(buildApplicationRefSum(applicationReferenceMetric, spanDecorator.getStartTime(), spanDecorator.getEndTime(), spanDecorator.getIsError()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ public class ApplicationReferenceMetricSpanListener implements EntrySpanListener
|
|||
}
|
||||
}
|
||||
|
||||
private ApplicationReferenceMetric buildNodeRefSum(ApplicationReferenceMetric reference,
|
||||
private ApplicationReferenceMetric buildApplicationRefSum(ApplicationReferenceMetric reference,
|
||||
long startTime, long endTime, boolean isError) {
|
||||
long duration = endTime - startTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,8 @@ public class InstanceMetricSpanListener implements EntrySpanListener, FirstSpanL
|
|||
|
||||
private int applicationId;
|
||||
private int instanceId;
|
||||
private long cost;
|
||||
private boolean isError;
|
||||
private long duration;
|
||||
private long timeBucket;
|
||||
|
||||
@Override
|
||||
|
|
@ -52,7 +53,8 @@ public class InstanceMetricSpanListener implements EntrySpanListener, FirstSpanL
|
|||
String segmentId) {
|
||||
this.applicationId = applicationId;
|
||||
this.instanceId = instanceId;
|
||||
this.cost = spanDecorator.getEndTime() - spanDecorator.getStartTime();
|
||||
this.isError = spanDecorator.getIsError();
|
||||
this.duration = spanDecorator.getEndTime() - spanDecorator.getStartTime();
|
||||
timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(spanDecorator.getStartTime());
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +63,12 @@ public class InstanceMetricSpanListener implements EntrySpanListener, FirstSpanL
|
|||
instanceMetric.setApplicationId(applicationId);
|
||||
instanceMetric.setInstanceId(instanceId);
|
||||
instanceMetric.setCalls(1);
|
||||
instanceMetric.setCostTotal(cost);
|
||||
instanceMetric.setDurationSum(duration);
|
||||
|
||||
if (isError) {
|
||||
instanceMetric.setErrorCalls(1);
|
||||
instanceMetric.setErrorDurationSum(duration);
|
||||
}
|
||||
instanceMetric.setTimeBucket(timeBucket);
|
||||
|
||||
Graph<InstanceMetric> graph = GraphManager.INSTANCE.createIfAbsent(TraceStreamGraph.INSTANCE_METRIC_GRAPH_ID, InstanceMetric.class);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
|
|||
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
|
||||
|
|
@ -122,7 +122,7 @@ public class StorageModule extends Module {
|
|||
classes.add(IMemoryPoolMetricUIDAO.class);
|
||||
|
||||
classes.add(IGlobalTraceUIDAO.class);
|
||||
classes.add(IInstPerformanceUIDAO.class);
|
||||
classes.add(IInstanceMetricUIDAO.class);
|
||||
classes.add(IApplicationComponentUIDAO.class);
|
||||
classes.add(IApplicationMappingUIDAO.class);
|
||||
classes.add(IApplicationReferenceMetricUIDAO.class);
|
||||
|
|
|
|||
|
|
@ -24,38 +24,38 @@ import org.skywalking.apm.collector.storage.base.dao.DAO;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IInstPerformanceUIDAO extends DAO {
|
||||
InstPerformance get(long[] timeBuckets, int instanceId);
|
||||
public interface IInstanceMetricUIDAO extends DAO {
|
||||
InstanceMetric get(long[] timeBuckets, int instanceId);
|
||||
|
||||
int getTpsMetric(int instanceId, long timeBucket);
|
||||
long getTpsMetric(int instanceId, long timeBucket);
|
||||
|
||||
JsonArray getTpsMetric(int instanceId, long startTimeBucket, long endTimeBucket);
|
||||
|
||||
int getRespTimeMetric(int instanceId, long timeBucket);
|
||||
long getRespTimeMetric(int instanceId, long timeBucket);
|
||||
|
||||
JsonArray getRespTimeMetric(int instanceId, long startTimeBucket, long endTimeBucket);
|
||||
|
||||
class InstPerformance {
|
||||
class InstanceMetric {
|
||||
private final int instanceId;
|
||||
private final int calls;
|
||||
private final long costTotal;
|
||||
private final long calls;
|
||||
private final long durationSum;
|
||||
|
||||
public InstPerformance(int instanceId, int calls, long costTotal) {
|
||||
public InstanceMetric(int instanceId, long calls, long durationSum) {
|
||||
this.instanceId = instanceId;
|
||||
this.calls = calls;
|
||||
this.costTotal = costTotal;
|
||||
this.durationSum = durationSum;
|
||||
}
|
||||
|
||||
public int getInstanceId() {
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public int getCalls() {
|
||||
public long getCalls() {
|
||||
return calls;
|
||||
}
|
||||
|
||||
public long getCostTotal() {
|
||||
return costTotal;
|
||||
public long getDurationSum() {
|
||||
return durationSum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,7 +34,10 @@ public class InstanceMetric extends Data {
|
|||
};
|
||||
|
||||
private static final Column[] LONG_COLUMNS = {
|
||||
new Column(InstanceMetricTable.COLUMN_COST_TOTAL, new AddOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_CALLS, new AddOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_ERROR_CALLS, new AddOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_DURATION_SUM, new AddOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()),
|
||||
};
|
||||
|
||||
|
|
@ -43,7 +46,6 @@ public class InstanceMetric extends Data {
|
|||
private static final Column[] INTEGER_COLUMNS = {
|
||||
new Column(InstanceMetricTable.COLUMN_APPLICATION_ID, new CoverOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_INSTANCE_ID, new CoverOperation()),
|
||||
new Column(InstanceMetricTable.COLUMN_CALLS, new AddOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BOOLEAN_COLUMNS = {};
|
||||
|
|
@ -53,22 +55,6 @@ public class InstanceMetric extends Data {
|
|||
super(id, STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BOOLEAN_COLUMNS, BYTE_COLUMNS);
|
||||
}
|
||||
|
||||
public Long getCostTotal() {
|
||||
return getDataLong(0);
|
||||
}
|
||||
|
||||
public void setCostTotal(Long costTotal) {
|
||||
setDataLong(0, costTotal);
|
||||
}
|
||||
|
||||
public Long getTimeBucket() {
|
||||
return getDataLong(1);
|
||||
}
|
||||
|
||||
public void setTimeBucket(Long timeBucket) {
|
||||
setDataLong(1, timeBucket);
|
||||
}
|
||||
|
||||
public Integer getApplicationId() {
|
||||
return getDataInteger(0);
|
||||
}
|
||||
|
|
@ -85,11 +71,43 @@ public class InstanceMetric extends Data {
|
|||
setDataInteger(1, instanceId);
|
||||
}
|
||||
|
||||
public Integer getCalls() {
|
||||
return getDataInteger(2);
|
||||
public long getCalls() {
|
||||
return getDataLong(0);
|
||||
}
|
||||
|
||||
public void setCalls(Integer calls) {
|
||||
setDataInteger(2, calls);
|
||||
public void setCalls(long calls) {
|
||||
setDataLong(0, calls);
|
||||
}
|
||||
|
||||
public long getErrorCalls() {
|
||||
return getDataLong(1);
|
||||
}
|
||||
|
||||
public void setErrorCalls(long errorCalls) {
|
||||
setDataLong(1, errorCalls);
|
||||
}
|
||||
|
||||
public long getDurationSum() {
|
||||
return getDataLong(2);
|
||||
}
|
||||
|
||||
public void setDurationSum(long durationSum) {
|
||||
setDataLong(2, durationSum);
|
||||
}
|
||||
|
||||
public long getErrorDurationSum() {
|
||||
return getDataLong(3);
|
||||
}
|
||||
|
||||
public void setErrorDurationSum(long errorDurationSum) {
|
||||
setDataLong(3, errorDurationSum);
|
||||
}
|
||||
|
||||
public Long getTimeBucket() {
|
||||
return getDataLong(4);
|
||||
}
|
||||
|
||||
public void setTimeBucket(Long timeBucket) {
|
||||
setDataLong(4, timeBucket);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,5 +28,7 @@ public class InstanceMetricTable extends CommonTable {
|
|||
public static final String COLUMN_APPLICATION_ID = "application_id";
|
||||
public static final String COLUMN_INSTANCE_ID = "instance_id";
|
||||
public static final String COLUMN_CALLS = "calls";
|
||||
public static final String COLUMN_COST_TOTAL = "cost_total";
|
||||
public static final String COLUMN_ERROR_CALLS = "error_calls";
|
||||
public static final String COLUMN_DURATION_SUM = "duration_sum";
|
||||
public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,15 +23,15 @@ import java.util.concurrent.Executors;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.ICpuMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IMemoryMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationComponentPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationMappingPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IServiceReferenceMetricPersistenceDAO;
|
||||
|
|
@ -94,17 +94,17 @@ public class DataTTLKeeperTimer {
|
|||
IGlobalTracePersistenceDAO globalTracePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTracePersistenceDAO.class);
|
||||
globalTracePersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
IInstanceMetricPersistenceDAO instPerformancePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricPersistenceDAO.class);
|
||||
instPerformancePersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
IInstanceMetricPersistenceDAO instanceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricPersistenceDAO.class);
|
||||
instanceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
IApplicationComponentPersistenceDAO nodeComponentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentPersistenceDAO.class);
|
||||
nodeComponentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
IApplicationComponentPersistenceDAO applicationComponentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentPersistenceDAO.class);
|
||||
applicationComponentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
IApplicationMappingPersistenceDAO nodeMappingPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingPersistenceDAO.class);
|
||||
nodeMappingPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
IApplicationMappingPersistenceDAO applicationMappingPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingPersistenceDAO.class);
|
||||
applicationMappingPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
IApplicationReferenceMetricPersistenceDAO nodeReferencePersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class);
|
||||
nodeReferencePersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
IApplicationReferenceMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricPersistenceDAO.class);
|
||||
applicationReferenceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
||||
ISegmentCostPersistenceDAO segmentCostPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class);
|
||||
segmentCostPersistenceDAO.deleteHistory(startTimestamp, endTimestamp);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
|
|||
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
|
||||
|
|
@ -83,7 +83,7 @@ import org.skywalking.apm.collector.storage.es.dao.GCMetricEsPersistenceDAO;
|
|||
import org.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.GlobalTraceEsUIDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.InstPerformanceEsUIDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.InstanceMetricEsUIDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.InstanceEsCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.InstanceEsRegisterDAO;
|
||||
import org.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO;
|
||||
|
|
@ -218,7 +218,7 @@ public class StorageModuleEsProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IMemoryPoolMetricUIDAO.class, new MemoryPoolMetricEsUIDAO(elasticSearchClient));
|
||||
|
||||
this.registerServiceImplementation(IGlobalTraceUIDAO.class, new GlobalTraceEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IInstPerformanceUIDAO.class, new InstPerformanceEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IInstanceMetricUIDAO.class, new InstanceMetricEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingEsUIDAO(elasticSearchClient));
|
||||
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient));
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationCo
|
|||
}
|
||||
|
||||
@Override public JsonArray load(long startTime, long endTime) {
|
||||
logger.debug("node component load, start time: {}, end time: {}", startTime, endTime);
|
||||
JsonArray nodeComponentArray = new JsonArray();
|
||||
nodeComponentArray.addAll(aggregationByComponentId(startTime, endTime));
|
||||
return nodeComponentArray;
|
||||
logger.debug("application component load, start time: {}, end time: {}", startTime, endTime);
|
||||
JsonArray applicationComponentArray = new JsonArray();
|
||||
applicationComponentArray.addAll(aggregationByComponentId(startTime, endTime));
|
||||
return applicationComponentArray;
|
||||
}
|
||||
|
||||
private JsonArray aggregationByComponentId(long startTime, long endTime) {
|
||||
|
|
@ -64,24 +64,25 @@ public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationCo
|
|||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
Terms componentIdTerms = searchResponse.getAggregations().get(ApplicationComponentTable.COLUMN_COMPONENT_ID);
|
||||
JsonArray nodeComponentArray = new JsonArray();
|
||||
JsonArray applicationComponentArray = new JsonArray();
|
||||
for (Terms.Bucket componentIdBucket : componentIdTerms.getBuckets()) {
|
||||
int componentId = componentIdBucket.getKeyAsNumber().intValue();
|
||||
buildComponentArray(componentIdBucket, componentId, nodeComponentArray);
|
||||
buildComponentArray(componentIdBucket, componentId, applicationComponentArray);
|
||||
}
|
||||
|
||||
return nodeComponentArray;
|
||||
return applicationComponentArray;
|
||||
}
|
||||
|
||||
private void buildComponentArray(Terms.Bucket componentBucket, int componentId, JsonArray nodeComponentArray) {
|
||||
private void buildComponentArray(Terms.Bucket componentBucket, int componentId,
|
||||
JsonArray applicationComponentArray) {
|
||||
Terms peerIdTerms = componentBucket.getAggregations().get(ApplicationComponentTable.COLUMN_PEER_ID);
|
||||
for (Terms.Bucket peerIdBucket : peerIdTerms.getBuckets()) {
|
||||
int peerId = peerIdBucket.getKeyAsNumber().intValue();
|
||||
|
||||
JsonObject nodeComponentObj = new JsonObject();
|
||||
nodeComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId);
|
||||
nodeComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId);
|
||||
nodeComponentArray.add(nodeComponentObj);
|
||||
JsonObject applicationComponentObj = new JsonObject();
|
||||
applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId);
|
||||
applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId);
|
||||
applicationComponentArray.add(applicationComponentObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,19 +58,19 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp
|
|||
|
||||
Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMappingTable.COLUMN_APPLICATION_ID);
|
||||
|
||||
JsonArray nodeMappingArray = new JsonArray();
|
||||
JsonArray applicationMappingArray = new JsonArray();
|
||||
for (Terms.Bucket applicationIdBucket : applicationIdTerms.getBuckets()) {
|
||||
int applicationId = applicationIdBucket.getKeyAsNumber().intValue();
|
||||
Terms addressIdTerms = applicationIdBucket.getAggregations().get(ApplicationMappingTable.COLUMN_ADDRESS_ID);
|
||||
for (Terms.Bucket addressIdBucket : addressIdTerms.getBuckets()) {
|
||||
int addressId = addressIdBucket.getKeyAsNumber().intValue();
|
||||
JsonObject nodeMappingObj = new JsonObject();
|
||||
nodeMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId);
|
||||
nodeMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId);
|
||||
nodeMappingArray.add(nodeMappingObj);
|
||||
JsonObject applicationMappingObj = new JsonObject();
|
||||
applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId);
|
||||
applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId);
|
||||
applicationMappingArray.add(applicationMappingObj);
|
||||
}
|
||||
}
|
||||
logger.debug("node mapping data: {}", nodeMappingArray.toString());
|
||||
return nodeMappingArray;
|
||||
logger.debug("application mapping data: {}", applicationMappingArray.toString());
|
||||
return applicationMappingArray;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
searchRequestBuilder.addAggregation(aggregationBuilder);
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
||||
JsonArray nodeRefResSumArray = new JsonArray();
|
||||
JsonArray applicationReferenceMetricArray = new JsonArray();
|
||||
// Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID);
|
||||
// for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) {
|
||||
// int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue();
|
||||
|
|
@ -94,6 +94,6 @@ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplica
|
|||
// }
|
||||
// }
|
||||
|
||||
return nodeRefResSumArray;
|
||||
return applicationReferenceMetricArray;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
|
|||
instanceMetric.setApplicationId((Integer)source.get(InstanceMetricTable.COLUMN_APPLICATION_ID));
|
||||
instanceMetric.setInstanceId((Integer)source.get(InstanceMetricTable.COLUMN_INSTANCE_ID));
|
||||
instanceMetric.setCalls((Integer)source.get(InstanceMetricTable.COLUMN_CALLS));
|
||||
instanceMetric.setCostTotal(((Number)source.get(InstanceMetricTable.COLUMN_COST_TOTAL)).longValue());
|
||||
instanceMetric.setErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_ERROR_CALLS)).longValue());
|
||||
instanceMetric.setDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_DURATION_SUM)).longValue());
|
||||
instanceMetric.setErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue());
|
||||
instanceMetric.setTimeBucket(((Number)source.get(InstanceMetricTable.COLUMN_TIME_BUCKET)).longValue());
|
||||
return instanceMetric;
|
||||
} else {
|
||||
|
|
@ -67,7 +69,9 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
|
|||
source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId());
|
||||
source.put(InstanceMetricTable.COLUMN_CALLS, data.getCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_COST_TOTAL, data.getCostTotal());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
|
||||
return getClient().prepareIndex(InstanceMetricTable.TABLE, data.getId()).setSource(source);
|
||||
|
|
@ -78,7 +82,9 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
|
|||
source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId());
|
||||
source.put(InstanceMetricTable.COLUMN_CALLS, data.getCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_COST_TOTAL, data.getCostTotal());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
|
||||
return getClient().prepareUpdate(InstanceMetricTable.TABLE, data.getId()).setDoc(source);
|
||||
|
|
|
|||
|
|
@ -34,20 +34,20 @@ import org.elasticsearch.search.sort.SortOrder;
|
|||
import org.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient;
|
||||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.es.base.dao.EsDAO;
|
||||
import org.skywalking.apm.collector.storage.table.instance.InstanceMetricTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstPerformanceEsUIDAO extends EsDAO implements IInstPerformanceUIDAO {
|
||||
public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO {
|
||||
|
||||
public InstPerformanceEsUIDAO(ElasticSearchClient client) {
|
||||
public InstanceMetricEsUIDAO(ElasticSearchClient client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public InstPerformance get(long[] timeBuckets, int instanceId) {
|
||||
@Override public InstanceMetric get(long[] timeBuckets, int instanceId) {
|
||||
SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceMetricTable.TABLE);
|
||||
searchRequestBuilder.setTypes(InstanceMetricTable.TABLE_TYPE);
|
||||
searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
|
||||
|
|
@ -61,20 +61,20 @@ public class InstPerformanceEsUIDAO extends EsDAO implements IInstPerformanceUID
|
|||
searchRequestBuilder.addSort(InstanceMetricTable.COLUMN_INSTANCE_ID, SortOrder.ASC);
|
||||
|
||||
searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_CALLS).field(InstanceMetricTable.COLUMN_CALLS));
|
||||
searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_COST_TOTAL).field(InstanceMetricTable.COLUMN_COST_TOTAL));
|
||||
searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_DURATION_SUM).field(InstanceMetricTable.COLUMN_DURATION_SUM));
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
Sum sumCalls = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_CALLS);
|
||||
Sum sumCostTotal = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_CALLS);
|
||||
return new InstPerformance(instanceId, (int)sumCalls.getValue(), (long)sumCostTotal.getValue());
|
||||
return new InstanceMetric(instanceId, (long)sumCalls.getValue(), (long)sumCostTotal.getValue());
|
||||
}
|
||||
|
||||
@Override public int getTpsMetric(int instanceId, long timeBucket) {
|
||||
@Override public long getTpsMetric(int instanceId, long timeBucket) {
|
||||
String id = timeBucket + Const.ID_SPLIT + instanceId;
|
||||
GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get();
|
||||
|
||||
if (getResponse.isExists()) {
|
||||
return ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).intValue();
|
||||
return ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ public class InstPerformanceEsUIDAO extends EsDAO implements IInstPerformanceUID
|
|||
MultiGetResponse multiGetResponse = prepareMultiGet.get();
|
||||
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
|
||||
if (response.getResponse().isExists()) {
|
||||
metrics.add(((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).intValue());
|
||||
metrics.add(((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue());
|
||||
} else {
|
||||
metrics.add(0);
|
||||
}
|
||||
|
|
@ -102,13 +102,13 @@ public class InstPerformanceEsUIDAO extends EsDAO implements IInstPerformanceUID
|
|||
return metrics;
|
||||
}
|
||||
|
||||
@Override public int getRespTimeMetric(int instanceId, long timeBucket) {
|
||||
@Override public long getRespTimeMetric(int instanceId, long timeBucket) {
|
||||
String id = timeBucket + Const.ID_SPLIT + instanceId;
|
||||
GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get();
|
||||
|
||||
if (getResponse.isExists()) {
|
||||
int callTimes = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).intValue();
|
||||
int costTotal = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_COST_TOTAL)).intValue();
|
||||
long callTimes = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
|
||||
long costTotal = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_DURATION_SUM)).longValue();
|
||||
return costTotal / callTimes;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -131,8 +131,8 @@ public class InstPerformanceEsUIDAO extends EsDAO implements IInstPerformanceUID
|
|||
MultiGetResponse multiGetResponse = prepareMultiGet.get();
|
||||
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
|
||||
if (response.getResponse().isExists()) {
|
||||
int callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).intValue();
|
||||
int costTotal = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_COST_TOTAL)).intValue();
|
||||
long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
|
||||
long costTotal = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_DURATION_SUM)).longValue();
|
||||
metrics.add(costTotal / callTimes);
|
||||
} else {
|
||||
metrics.add(0);
|
||||
|
|
@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.instance.InstanceMetricTable;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstPerformanceEsTableDefine extends ElasticSearchTableDefine {
|
||||
public class InstanceMetricEsTableDefine extends ElasticSearchTableDefine {
|
||||
|
||||
public InstPerformanceEsTableDefine() {
|
||||
public InstanceMetricEsTableDefine() {
|
||||
super(InstanceMetricTable.TABLE);
|
||||
}
|
||||
|
||||
|
|
@ -38,8 +38,10 @@ public class InstPerformanceEsTableDefine extends ElasticSearchTableDefine {
|
|||
@Override public void initialize() {
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_CALLS, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_COST_TOTAL, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ org.skywalking.apm.collector.storage.es.define.GCMetricEsTableDefine
|
|||
org.skywalking.apm.collector.storage.es.define.MemoryMetricEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.MemoryPoolMetricEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.InstPerformanceEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.InstanceMetricEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.ApplicationComponentEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.ApplicationMappingEsTableDefine
|
||||
org.skywalking.apm.collector.storage.es.define.ApplicationReferenceMetricEsTableDefine
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import org.skywalking.apm.collector.storage.dao.IGCMetricPersistenceDAO;
|
|||
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricPersistenceDAO;
|
||||
|
|
@ -78,7 +78,7 @@ import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2PersistenceDAO;
|
|||
import org.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.InstPerformanceH2UIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2UIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2CacheDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2RegisterDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO;
|
||||
|
|
@ -195,7 +195,7 @@ public class StorageModuleH2Provider extends ModuleProvider {
|
|||
this.registerServiceImplementation(IMemoryPoolMetricUIDAO.class, new MemoryPoolMetricH2UIDAO(h2Client));
|
||||
|
||||
this.registerServiceImplementation(IGlobalTraceUIDAO.class, new GlobalTraceH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IInstPerformanceUIDAO.class, new InstPerformanceH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IInstanceMetricUIDAO.class, new InstanceMetricH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingH2UIDAO(h2Client));
|
||||
this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client));
|
||||
|
|
|
|||
|
|
@ -44,15 +44,15 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo
|
|||
}
|
||||
|
||||
@Override public JsonArray load(long startTime, long endTime) {
|
||||
JsonArray nodeComponentArray = new JsonArray();
|
||||
nodeComponentArray.addAll(aggregationComponent(startTime, endTime));
|
||||
return nodeComponentArray;
|
||||
JsonArray applicationComponentArray = new JsonArray();
|
||||
applicationComponentArray.addAll(aggregationComponent(startTime, endTime));
|
||||
return applicationComponentArray;
|
||||
}
|
||||
|
||||
private JsonArray aggregationComponent(long startTime, long endTime) {
|
||||
H2Client client = getClient();
|
||||
|
||||
JsonArray nodeComponentArray = new JsonArray();
|
||||
JsonArray applicationComponentArray = new JsonArray();
|
||||
String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_PEER_ID,
|
||||
ApplicationComponentTable.TABLE, ApplicationComponentTable.COLUMN_TIME_BUCKET);
|
||||
Object[] params = new Object[] {startTime, endTime};
|
||||
|
|
@ -60,14 +60,14 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo
|
|||
while (rs.next()) {
|
||||
int peerId = rs.getInt(ApplicationComponentTable.COLUMN_PEER_ID);
|
||||
int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID);
|
||||
JsonObject nodeComponentObj = new JsonObject();
|
||||
nodeComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId);
|
||||
nodeComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId);
|
||||
nodeComponentArray.add(nodeComponentObj);
|
||||
JsonObject applicationComponentObj = new JsonObject();
|
||||
applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId);
|
||||
applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId);
|
||||
applicationComponentArray.add(applicationComponentObj);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return nodeComponentArray;
|
||||
return applicationComponentArray;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMappingUIDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationMappingH2UIDAO.class);
|
||||
private static final String NODE_MAPPING_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100";
|
||||
private static final String APPLICATION_MAPPING_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100";
|
||||
|
||||
public ApplicationMappingH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
|
|
@ -45,8 +45,8 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp
|
|||
|
||||
@Override public JsonArray load(long startTime, long endTime) {
|
||||
H2Client client = getClient();
|
||||
JsonArray nodeMappingArray = new JsonArray();
|
||||
String sql = SqlBuilder.buildSql(NODE_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID,
|
||||
JsonArray applicationMappingArray = new JsonArray();
|
||||
String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID,
|
||||
ApplicationMappingTable.COLUMN_ADDRESS_ID, ApplicationMappingTable.TABLE, ApplicationMappingTable.COLUMN_TIME_BUCKET);
|
||||
|
||||
Object[] params = new Object[] {startTime, endTime};
|
||||
|
|
@ -54,15 +54,15 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp
|
|||
while (rs.next()) {
|
||||
int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID);
|
||||
int addressId = rs.getInt(ApplicationMappingTable.COLUMN_ADDRESS_ID);
|
||||
JsonObject nodeMappingObj = new JsonObject();
|
||||
nodeMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId);
|
||||
nodeMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId);
|
||||
nodeMappingArray.add(nodeMappingObj);
|
||||
JsonObject applicationMappingObj = new JsonObject();
|
||||
applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId);
|
||||
applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId);
|
||||
applicationMappingArray.add(applicationMappingObj);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
logger.debug("node mapping data: {}", nodeMappingArray.toString());
|
||||
return nodeMappingArray;
|
||||
logger.debug("node mapping data: {}", applicationMappingArray.toString());
|
||||
return applicationMappingArray;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,9 @@
|
|||
package org.skywalking.apm.collector.storage.h2.dao;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.skywalking.apm.collector.core.util.ColumnNameUtils;
|
||||
import org.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -38,7 +31,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplicationReferenceMetricUIDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricH2UIDAO.class);
|
||||
private static final String NODE_REFERENCE_SQL = "select {8}, {9}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " +
|
||||
private static final String APPLICATION_REFERENCE_SQL = "select {8}, {9}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " +
|
||||
"sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9} limit 100";
|
||||
|
||||
public ApplicationReferenceMetricH2UIDAO(H2Client client) {
|
||||
|
|
@ -47,8 +40,8 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
|
|||
|
||||
@Override public JsonArray load(long startTime, long endTime) {
|
||||
H2Client client = getClient();
|
||||
JsonArray nodeRefResSumArray = new JsonArray();
|
||||
// String sql = SqlBuilder.buildSql(NODE_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
|
||||
JsonArray applicationReferenceMetricArray = new JsonArray();
|
||||
// String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE,
|
||||
// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE,
|
||||
// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY,
|
||||
// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET,
|
||||
|
|
@ -73,6 +66,6 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica
|
|||
// } catch (SQLException | H2ClientException e) {
|
||||
// logger.error(e.getMessage(), e);
|
||||
// }
|
||||
return nodeRefResSumArray;
|
||||
return applicationReferenceMetricArray;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,8 +56,10 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe
|
|||
InstanceMetric instanceMetric = new InstanceMetric(id);
|
||||
instanceMetric.setApplicationId(rs.getInt(InstanceMetricTable.COLUMN_APPLICATION_ID));
|
||||
instanceMetric.setInstanceId(rs.getInt(InstanceMetricTable.COLUMN_INSTANCE_ID));
|
||||
instanceMetric.setCalls(rs.getInt(InstanceMetricTable.COLUMN_CALLS));
|
||||
instanceMetric.setCostTotal(rs.getLong(InstanceMetricTable.COLUMN_COST_TOTAL));
|
||||
instanceMetric.setCalls(rs.getLong(InstanceMetricTable.COLUMN_CALLS));
|
||||
instanceMetric.setErrorCalls(rs.getLong(InstanceMetricTable.COLUMN_ERROR_CALLS));
|
||||
instanceMetric.setDurationSum(rs.getLong(InstanceMetricTable.COLUMN_DURATION_SUM));
|
||||
instanceMetric.setErrorDurationSum(rs.getLong(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM));
|
||||
instanceMetric.setTimeBucket(rs.getLong(InstanceMetricTable.COLUMN_TIME_BUCKET));
|
||||
return instanceMetric;
|
||||
}
|
||||
|
|
@ -74,7 +76,9 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe
|
|||
source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId());
|
||||
source.put(InstanceMetricTable.COLUMN_CALLS, data.getCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_COST_TOTAL, data.getCostTotal());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
String sql = SqlBuilder.buildBatchInsertSql(InstanceMetricTable.TABLE, source.keySet());
|
||||
entity.setSql(sql);
|
||||
|
|
@ -88,7 +92,9 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe
|
|||
source.put(InstanceMetricTable.COLUMN_APPLICATION_ID, data.getApplicationId());
|
||||
source.put(InstanceMetricTable.COLUMN_INSTANCE_ID, data.getInstanceId());
|
||||
source.put(InstanceMetricTable.COLUMN_CALLS, data.getCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_COST_TOTAL, data.getCostTotal());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
|
||||
source.put(InstanceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
|
||||
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
|
||||
String sql = SqlBuilder.buildBatchUpdateSql(InstanceMetricTable.TABLE, source.keySet(), InstanceMetricTable.COLUMN_ID);
|
||||
entity.setSql(sql);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.skywalking.apm.collector.client.h2.H2ClientException;
|
|||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.skywalking.apm.collector.storage.table.instance.InstanceMetricTable;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -37,20 +37,20 @@ import org.slf4j.LoggerFactory;
|
|||
/**
|
||||
* @author peng-yongsheng, clevertension
|
||||
*/
|
||||
public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUIDAO {
|
||||
public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstPerformanceH2UIDAO.class);
|
||||
private static final String GET_INST_PERF_SQL = "select * from {0} where {1} = ? and {2} in (";
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceMetricH2UIDAO.class);
|
||||
private static final String GET_INSTANCE_METRIC_SQL = "select * from {0} where {1} = ? and {2} in (";
|
||||
private static final String GET_TPS_METRIC_SQL = "select * from {0} where {1} = ?";
|
||||
|
||||
public InstPerformanceH2UIDAO(H2Client client) {
|
||||
public InstanceMetricH2UIDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public InstPerformance get(long[] timeBuckets, int instanceId) {
|
||||
@Override public InstanceMetric get(long[] timeBuckets, int instanceId) {
|
||||
H2Client client = getClient();
|
||||
logger.info("the inst performance inst id = {}", instanceId);
|
||||
String sql = SqlBuilder.buildSql(GET_INST_PERF_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_INSTANCE_ID, InstanceMetricTable.COLUMN_TIME_BUCKET);
|
||||
String sql = SqlBuilder.buildSql(GET_INSTANCE_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_INSTANCE_ID, InstanceMetricTable.COLUMN_TIME_BUCKET);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < timeBuckets.length; i++) {
|
||||
builder.append("?,");
|
||||
|
|
@ -65,9 +65,9 @@ public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUID
|
|||
params[0] = instanceId;
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
int callTimes = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
int costTotal = rs.getInt(InstanceMetricTable.COLUMN_COST_TOTAL);
|
||||
return new InstPerformance(instanceId, callTimes, costTotal);
|
||||
long callTimes = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
long costTotal = rs.getInt(InstanceMetricTable.COLUMN_DURATION_SUM);
|
||||
return new InstanceMetric(instanceId, callTimes, costTotal);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
|
@ -75,14 +75,14 @@ public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUID
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override public int getTpsMetric(int instanceId, long timeBucket) {
|
||||
@Override public long getTpsMetric(int instanceId, long timeBucket) {
|
||||
logger.info("getTpMetric instanceId = {}, startTimeBucket = {}", instanceId, timeBucket);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID);
|
||||
Object[] params = new Object[] {instanceId};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
return rs.getLong(InstanceMetricTable.COLUMN_CALLS);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
|
|
@ -108,7 +108,7 @@ public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUID
|
|||
idList.forEach(id -> {
|
||||
try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) {
|
||||
if (rs.next()) {
|
||||
int calls = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
long calls = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
|
||||
metrics.add(calls);
|
||||
} else {
|
||||
metrics.add(0);
|
||||
|
|
@ -120,14 +120,14 @@ public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUID
|
|||
return metrics;
|
||||
}
|
||||
|
||||
@Override public int getRespTimeMetric(int instanceId, long timeBucket) {
|
||||
@Override public long getRespTimeMetric(int instanceId, long timeBucket) {
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID);
|
||||
Object[] params = new Object[] {instanceId};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
int callTimes = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
int costTotal = rs.getInt(InstanceMetricTable.COLUMN_COST_TOTAL);
|
||||
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
|
||||
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_DURATION_SUM);
|
||||
return costTotal / callTimes;
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
|
|
@ -153,8 +153,8 @@ public class InstPerformanceH2UIDAO extends H2DAO implements IInstPerformanceUID
|
|||
idList.forEach(id -> {
|
||||
try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) {
|
||||
if (rs.next()) {
|
||||
int callTimes = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
|
||||
int costTotal = rs.getInt(InstanceMetricTable.COLUMN_COST_TOTAL);
|
||||
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
|
||||
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_DURATION_SUM);
|
||||
metrics.add(costTotal / callTimes);
|
||||
} else {
|
||||
metrics.add(0);
|
||||
|
|
@ -25,9 +25,9 @@ import org.skywalking.apm.collector.storage.table.instance.InstanceMetricTable;
|
|||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstPerformanceH2TableDefine extends H2TableDefine {
|
||||
public class InstanceMetricH2TableDefine extends H2TableDefine {
|
||||
|
||||
public InstPerformanceH2TableDefine() {
|
||||
public InstanceMetricH2TableDefine() {
|
||||
super(InstanceMetricTable.TABLE);
|
||||
}
|
||||
|
||||
|
|
@ -35,8 +35,10 @@ public class InstPerformanceH2TableDefine extends H2TableDefine {
|
|||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_CALLS, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_COST_TOTAL, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_CALLS, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ org.skywalking.apm.collector.storage.h2.define.GCMetricH2TableDefine
|
|||
org.skywalking.apm.collector.storage.h2.define.MemoryMetricH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.MemoryPoolMetricH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.GlobalTraceH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.InstPerformanceH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.InstanceMetricH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.ApplicationComponentH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.ApplicationMappingH2TableDefine
|
||||
org.skywalking.apm.collector.storage.h2.define.ApplicationReferenceMetricH2TableDefine
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.skywalking.apm.collector.core.module.ModuleManager;
|
|||
import org.skywalking.apm.collector.core.util.TimeBucketUtils;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.table.register.Instance;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -42,13 +42,13 @@ public class InstanceHealthService {
|
|||
|
||||
private final IGCMetricUIDAO gcMetricDAO;
|
||||
private final IInstanceUIDAO instanceDAO;
|
||||
private final IInstPerformanceUIDAO instPerformanceDAO;
|
||||
private final IInstanceMetricUIDAO instanceMetricUIDAO;
|
||||
private final ApplicationCacheService applicationCacheService;
|
||||
|
||||
public InstanceHealthService(ModuleManager moduleManager) {
|
||||
this.gcMetricDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
this.instPerformanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstPerformanceUIDAO.class);
|
||||
this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class);
|
||||
this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class);
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ public class InstanceHealthService {
|
|||
response.addProperty("applicationCode", applicationCacheService.get(applicationId));
|
||||
response.addProperty("applicationId", applicationId);
|
||||
|
||||
IInstPerformanceUIDAO.InstPerformance performance = instPerformanceDAO.get(timeBuckets, instance.getInstanceId());
|
||||
IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId());
|
||||
|
||||
JsonObject instanceJson = new JsonObject();
|
||||
instanceJson.addProperty("id", instance.getInstanceId());
|
||||
|
|
@ -78,7 +78,7 @@ public class InstanceHealthService {
|
|||
|
||||
int avg = 0;
|
||||
if (performance != null && performance.getCalls() != 0) {
|
||||
avg = (int)(performance.getCostTotal() / performance.getCalls());
|
||||
avg = (int)(performance.getDurationSum() / performance.getCalls());
|
||||
}
|
||||
instanceJson.addProperty("avg", avg);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.skywalking.apm.collector.core.util.ObjectUtils;
|
|||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IGCMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstPerformanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO;
|
||||
import org.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO;
|
||||
|
|
@ -50,7 +50,7 @@ public class InstanceJVMService {
|
|||
private final IGCMetricUIDAO gcMetricDAO;
|
||||
private final IMemoryMetricUIDAO memoryMetricDAO;
|
||||
private final IMemoryPoolMetricUIDAO memoryPoolMetricDAO;
|
||||
private final IInstPerformanceUIDAO instPerformanceDAO;
|
||||
private final IInstanceMetricUIDAO instanceMetricUIDAO;
|
||||
|
||||
public InstanceJVMService(ModuleManager moduleManager) {
|
||||
this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class);
|
||||
|
|
@ -58,7 +58,7 @@ public class InstanceJVMService {
|
|||
this.gcMetricDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class);
|
||||
this.memoryMetricDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class);
|
||||
this.memoryPoolMetricDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryPoolMetricUIDAO.class);
|
||||
this.instPerformanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstPerformanceUIDAO.class);
|
||||
this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class);
|
||||
}
|
||||
|
||||
public JsonObject getInstanceOsInfo(int instanceId) {
|
||||
|
|
@ -78,9 +78,9 @@ public class InstanceJVMService {
|
|||
} else if (metricType.toLowerCase().equals(MetricType.gc.name())) {
|
||||
metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, timeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.tps.name())) {
|
||||
metrics.addProperty(MetricType.tps.name(), instPerformanceDAO.getTpsMetric(instanceId, timeBucket));
|
||||
metrics.addProperty(MetricType.tps.name(), instanceMetricUIDAO.getTpsMetric(instanceId, timeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.resptime.name())) {
|
||||
metrics.addProperty(MetricType.resptime.name(), instPerformanceDAO.getRespTimeMetric(instanceId, timeBucket));
|
||||
metrics.addProperty(MetricType.resptime.name(), instanceMetricUIDAO.getRespTimeMetric(instanceId, timeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) {
|
||||
metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, timeBucket, true));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) {
|
||||
|
|
@ -111,9 +111,9 @@ public class InstanceJVMService {
|
|||
} else if (metricType.toLowerCase().equals(MetricType.gc.name())) {
|
||||
metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.tps.name())) {
|
||||
metrics.add(MetricType.tps.name(), instPerformanceDAO.getTpsMetric(instanceId, startTimeBucket, endTimeBucket));
|
||||
metrics.add(MetricType.tps.name(), instanceMetricUIDAO.getTpsMetric(instanceId, startTimeBucket, endTimeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.resptime.name())) {
|
||||
metrics.add(MetricType.resptime.name(), instPerformanceDAO.getRespTimeMetric(instanceId, startTimeBucket, endTimeBucket));
|
||||
metrics.add(MetricType.resptime.name(), instanceMetricUIDAO.getRespTimeMetric(instanceId, startTimeBucket, endTimeBucket));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) {
|
||||
metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, true));
|
||||
} else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) {
|
||||
|
|
|
|||
|
|
@ -35,28 +35,28 @@ public class TraceDagService {
|
|||
|
||||
private final Logger logger = LoggerFactory.getLogger(TraceDagService.class);
|
||||
|
||||
private final IApplicationComponentUIDAO nodeComponentDAO;
|
||||
private final IApplicationMappingUIDAO nodeMappingDAO;
|
||||
private final IApplicationReferenceMetricUIDAO nodeRefSumDAO;
|
||||
private final IApplicationComponentUIDAO applicationComponentUIDAO;
|
||||
private final IApplicationMappingUIDAO applicationMappingUIDAO;
|
||||
private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO;
|
||||
private final ModuleManager moduleManager;
|
||||
|
||||
public TraceDagService(ModuleManager moduleManager) {
|
||||
this.moduleManager = moduleManager;
|
||||
this.nodeComponentDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class);
|
||||
this.nodeMappingDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class);
|
||||
this.nodeRefSumDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class);
|
||||
this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class);
|
||||
this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class);
|
||||
this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class);
|
||||
}
|
||||
|
||||
public JsonObject load(long startTime, long endTime) {
|
||||
logger.debug("startTime: {}, endTime: {}", startTime, endTime);
|
||||
JsonArray nodeComponentArray = nodeComponentDAO.load(startTime, endTime);
|
||||
JsonArray applicationComponentArray = applicationComponentUIDAO.load(startTime, endTime);
|
||||
|
||||
JsonArray nodeMappingArray = nodeMappingDAO.load(startTime, endTime);
|
||||
JsonArray applicationMappingArray = applicationMappingUIDAO.load(startTime, endTime);
|
||||
|
||||
JsonArray nodeRefSumArray = nodeRefSumDAO.load(startTime, endTime);
|
||||
JsonArray applicationReferenceMetricArray = applicationReferenceMetricUIDAO.load(startTime, endTime);
|
||||
|
||||
TraceDagDataBuilder builder = new TraceDagDataBuilder(moduleManager);
|
||||
JsonObject traceDag = builder.build(nodeComponentArray, nodeMappingArray, nodeRefSumArray);
|
||||
JsonObject traceDag = builder.build(applicationComponentArray, applicationMappingArray, applicationReferenceMetricArray);
|
||||
|
||||
return traceDag;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue