提交 2a034929 编写于 作者: P peng-yongsheng

Make instance metric contains transaction, business transaction, mq transaction.

上级 e64e2c3f
......@@ -62,12 +62,12 @@ public class InstanceMetricSpanListener implements EntrySpanListener, FirstSpanL
InstanceMetric instanceMetric = new InstanceMetric(timeBucket + Const.ID_SPLIT + instanceId);
instanceMetric.setApplicationId(applicationId);
instanceMetric.setInstanceId(instanceId);
instanceMetric.setCalls(1);
instanceMetric.setDurationSum(duration);
instanceMetric.setTransactionCalls(1L);
instanceMetric.setTransactionDurationSum(duration);
if (isError) {
instanceMetric.setErrorCalls(1);
instanceMetric.setErrorDurationSum(duration);
instanceMetric.setTransactionErrorCalls(1L);
instanceMetric.setTransactionErrorDurationSum(duration);
}
instanceMetric.setTimeBucket(timeBucket);
......
......@@ -34,11 +34,20 @@ public class InstanceMetric extends Data {
};
private static final Column[] LONG_COLUMNS = {
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()),
new Column(InstanceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()),
new Column(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
......@@ -71,43 +80,107 @@ public class InstanceMetric extends Data {
setDataInteger(1, instanceId);
}
public long getCalls() {
public Long getTimeBucket() {
return getDataLong(0);
}
public void setCalls(long calls) {
setDataLong(0, calls);
public void setTimeBucket(Long timeBucket) {
setDataLong(0, timeBucket);
}
public long getErrorCalls() {
public Long getTransactionCalls() {
return getDataLong(1);
}
public void setErrorCalls(long errorCalls) {
setDataLong(1, errorCalls);
public void setTransactionCalls(Long transactionCalls) {
setDataLong(1, transactionCalls);
}
public long getDurationSum() {
public Long getTransactionErrorCalls() {
return getDataLong(2);
}
public void setDurationSum(long durationSum) {
setDataLong(2, durationSum);
public void setTransactionErrorCalls(Long transactionErrorCalls) {
setDataLong(2, transactionErrorCalls);
}
public long getErrorDurationSum() {
public Long getTransactionDurationSum() {
return getDataLong(3);
}
public void setErrorDurationSum(long errorDurationSum) {
setDataLong(3, errorDurationSum);
public void setTransactionDurationSum(Long transactionDurationSum) {
setDataLong(3, transactionDurationSum);
}
public Long getTimeBucket() {
public Long getTransactionErrorDurationSum() {
return getDataLong(4);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(4, timeBucket);
public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) {
setDataLong(4, transactionErrorDurationSum);
}
public Long getBusinessTransactionCalls() {
return getDataLong(5);
}
public void setBusinessTransactionCalls(Long businessTransactionCalls) {
setDataLong(5, businessTransactionCalls);
}
public Long getBusinessTransactionErrorCalls() {
return getDataLong(6);
}
public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) {
setDataLong(6, businessTransactionErrorCalls);
}
public Long getBusinessTransactionDurationSum() {
return getDataLong(7);
}
public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) {
setDataLong(7, businessTransactionDurationSum);
}
public Long getBusinessTransactionErrorDurationSum() {
return getDataLong(8);
}
public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) {
setDataLong(8, businessTransactionErrorDurationSum);
}
public Long getMqTransactionCalls() {
return getDataLong(9);
}
public void setMqTransactionCalls(Long mqTransactionCalls) {
setDataLong(9, mqTransactionCalls);
}
public Long getMqTransactionErrorCalls() {
return getDataLong(10);
}
public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) {
setDataLong(10, mqTransactionErrorCalls);
}
public Long getMqTransactionDurationSum() {
return getDataLong(11);
}
public void setMqTransactionDurationSum(Long mqTransactionDurationSum) {
setDataLong(11, mqTransactionDurationSum);
}
public Long getMqTransactionErrorDurationSum() {
return getDataLong(12);
}
public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) {
setDataLong(12, mqTransactionErrorDurationSum);
}
}
......@@ -18,17 +18,13 @@
package org.skywalking.apm.collector.storage.table.instance;
import org.skywalking.apm.collector.core.data.CommonTable;
import org.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class InstanceMetricTable extends CommonTable {
public class InstanceMetricTable extends CommonMetricTable {
public static final String TABLE = "instance_metric";
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_ERROR_CALLS = "error_calls";
public static final String COLUMN_DURATION_SUM = "duration_sum";
public static final String COLUMN_ERROR_DURATION_SUM = "error_duration_sum";
}
......@@ -33,20 +33,20 @@ public class ServiceMetric extends Data {
};
private static final Column[] LONG_COLUMNS = {
new Column(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceReferenceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_TIME_BUCKET, new NonOperation()),
new Column(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, new AddOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
......
......@@ -53,11 +53,24 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
Map<String, Object> source = getResponse.getSource();
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.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.setTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue());
instanceMetric.setTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue());
instanceMetric.setTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue());
instanceMetric.setTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue());
instanceMetric.setBusinessTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue());
instanceMetric.setBusinessTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue());
instanceMetric.setBusinessTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue());
instanceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue());
instanceMetric.setMqTransactionCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue());
instanceMetric.setMqTransactionErrorCalls(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue());
instanceMetric.setMqTransactionDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue());
instanceMetric.setMqTransactionErrorDurationSum(((Number)source.get(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue());
instanceMetric.setTimeBucket(((Number)source.get(InstanceMetricTable.COLUMN_TIME_BUCKET)).longValue());
return instanceMetric;
} else {
return null;
......@@ -68,10 +81,22 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
Map<String, Object> source = new HashMap<>();
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_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_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareIndex(InstanceMetricTable.TABLE, data.getId()).setSource(source);
......@@ -81,10 +106,22 @@ public class InstanceMetricEsPersistenceDAO extends EsDAO implements IInstanceMe
Map<String, Object> source = new HashMap<>();
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_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_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareUpdate(InstanceMetricTable.TABLE, data.getId()).setDoc(source);
......
......@@ -60,12 +60,12 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
searchRequestBuilder.setSize(0);
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_DURATION_SUM).field(InstanceMetricTable.COLUMN_DURATION_SUM));
searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_CALLS).field(InstanceMetricTable.COLUMN_TRANSACTION_CALLS));
searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
Sum sumCalls = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_CALLS);
Sum sumCostTotal = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_CALLS);
Sum sumCalls = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
Sum sumCostTotal = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
return new InstanceMetric(instanceId, (long)sumCalls.getValue(), (long)sumCostTotal.getValue());
}
......@@ -74,7 +74,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get();
if (getResponse.isExists()) {
return ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
return ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
}
return 0;
}
......@@ -94,7 +94,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
metrics.add(((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue());
metrics.add(((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue());
} else {
metrics.add(0);
}
......@@ -107,8 +107,8 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get();
if (getResponse.isExists()) {
long callTimes = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
long costTotal = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_DURATION_SUM)).longValue();
long callTimes = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long costTotal = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue();
return costTotal / callTimes;
}
return 0;
......@@ -131,8 +131,8 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO
MultiGetResponse multiGetResponse = prepareMultiGet.get();
for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
if (response.getResponse().isExists()) {
long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_CALLS)).longValue();
long costTotal = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_DURATION_SUM)).longValue();
long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
long costTotal = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue();
metrics.add(costTotal / callTimes);
} else {
metrics.add(0);
......
......@@ -38,10 +38,22 @@ public class InstanceMetricEsTableDefine 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.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_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(InstanceMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
}
}
......@@ -56,10 +56,22 @@ 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.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.setTransactionCalls(rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS));
instanceMetric.setTransactionErrorCalls(rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS));
instanceMetric.setTransactionDurationSum(rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
instanceMetric.setTransactionErrorDurationSum(rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM));
instanceMetric.setBusinessTransactionCalls(rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS));
instanceMetric.setBusinessTransactionErrorCalls(rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS));
instanceMetric.setBusinessTransactionDurationSum(rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM));
instanceMetric.setBusinessTransactionErrorDurationSum(rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM));
instanceMetric.setMqTransactionCalls(rs.getLong(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS));
instanceMetric.setMqTransactionErrorCalls(rs.getLong(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS));
instanceMetric.setMqTransactionDurationSum(rs.getLong(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM));
instanceMetric.setMqTransactionErrorDurationSum(rs.getLong(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM));
instanceMetric.setTimeBucket(rs.getLong(InstanceMetricTable.COLUMN_TIME_BUCKET));
return instanceMetric;
}
......@@ -75,10 +87,22 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe
source.put(InstanceMetricTable.COLUMN_ID, data.getId());
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_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_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchInsertSql(InstanceMetricTable.TABLE, source.keySet());
entity.setSql(sql);
......@@ -91,10 +115,22 @@ public class InstanceMetricH2PersistenceDAO extends H2DAO implements IInstanceMe
H2SqlEntity entity = new H2SqlEntity();
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_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_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(InstanceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchUpdateSql(InstanceMetricTable.TABLE, source.keySet(), InstanceMetricTable.COLUMN_ID);
entity.setSql(sql);
......
......@@ -65,8 +65,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
params[0] = instanceId;
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
long callTimes = rs.getInt(InstanceMetricTable.COLUMN_CALLS);
long costTotal = rs.getInt(InstanceMetricTable.COLUMN_DURATION_SUM);
long callTimes = rs.getInt(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
long costTotal = rs.getInt(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
return new InstanceMetric(instanceId, callTimes, costTotal);
}
} catch (SQLException | H2ClientException e) {
......@@ -82,7 +82,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
Object[] params = new Object[] {instanceId};
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
return rs.getLong(InstanceMetricTable.COLUMN_CALLS);
return rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
......@@ -108,7 +108,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
idList.forEach(id -> {
try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) {
if (rs.next()) {
long calls = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
long calls = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
metrics.add(calls);
} else {
metrics.add(0);
......@@ -126,8 +126,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
Object[] params = new Object[] {instanceId};
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_DURATION_SUM);
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
return costTotal / callTimes;
}
} catch (SQLException | H2ClientException e) {
......@@ -153,8 +153,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
idList.forEach(id -> {
try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) {
if (rs.next()) {
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_CALLS);
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_DURATION_SUM);
long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
long costTotal = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
metrics.add(costTotal / callTimes);
} else {
metrics.add(0);
......
......@@ -35,10 +35,22 @@ public class InstanceMetricH2TableDefine 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.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_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(InstanceMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册