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

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

上级 6d027a72
......@@ -44,10 +44,10 @@ public class ServiceMetricAggregationWorker extends AggregationWorker<ServiceRef
Long timeBucket = serviceReferenceMetric.getTimeBucket();
ServiceMetric serviceMetric = new ServiceMetric(String.valueOf(timeBucket) + Const.ID_SPLIT + String.valueOf(serviceId));
serviceMetric.setServiceId(serviceId);
serviceMetric.setCalls(serviceReferenceMetric.getCalls());
serviceMetric.setErrorCalls(serviceReferenceMetric.getErrorCalls());
serviceMetric.setDurationSum(serviceReferenceMetric.getDurationSum());
serviceMetric.setErrorDurationSum(serviceReferenceMetric.getErrorDurationSum());
// serviceMetric.setCalls(serviceReferenceMetric.getCalls());
// serviceMetric.setErrorCalls(serviceReferenceMetric.getErrorCalls());
// serviceMetric.setDurationSum(serviceReferenceMetric.getDurationSum());
// serviceMetric.setErrorDurationSum(serviceReferenceMetric.getErrorDurationSum());
serviceMetric.setTimeBucket(timeBucket);
return serviceMetric;
......
......@@ -74,12 +74,12 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
long endTime, boolean isError) {
long duration = endTime - startTime;
serviceReferenceMetric.setCalls(1L);
serviceReferenceMetric.setDurationSum(duration);
serviceReferenceMetric.setTransactionCalls(1L);
serviceReferenceMetric.setTransactionDurationSum(duration);
if (isError) {
serviceReferenceMetric.setErrorCalls(1L);
serviceReferenceMetric.setErrorDurationSum(duration);
serviceReferenceMetric.setTransactionErrorCalls(1L);
serviceReferenceMetric.setTransactionErrorDurationSum(duration);
}
}
......
......@@ -21,7 +21,7 @@ package org.skywalking.apm.collector.core.data;
/**
* @author peng-yongsheng
*/
public class CommonTable {
public abstract class CommonTable {
public static final String TABLE_TYPE = "type";
public static final String COLUMN_ID = "id";
public static final String COLUMN_AGG = "agg";
......
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.collector.storage.table;
import org.skywalking.apm.collector.core.data.CommonTable;
/**
* @author peng-yongsheng
*/
public abstract class CommonMetricTable extends CommonTable {
public static final String COLUMN_TRANSACTION_CALLS = "transaction_calls";
public static final String COLUMN_TRANSACTION_ERROR_CALLS = "transaction_error_calls";
public static final String COLUMN_TRANSACTION_DURATION_SUM = "transaction_duration_sum";
public static final String COLUMN_TRANSACTION_ERROR_DURATION_SUM = "transaction_error_duration_sum";
public static final String COLUMN_BUSINESS_TRANSACTION_CALLS = "business_transaction_calls";
public static final String COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS = "business_transaction_error_calls";
public static final String COLUMN_BUSINESS_TRANSACTION_DURATION_SUM = "business_transaction_duration_sum";
public static final String COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM = "business_transaction_error_duration_sum";
public static final String COLUMN_MQ_TRANSACTION_CALLS = "mq_transaction_calls";
public static final String COLUMN_MQ_TRANSACTION_ERROR_CALLS = "mq_transaction_error_calls";
public static final String COLUMN_MQ_TRANSACTION_DURATION_SUM = "mq_transaction_duration_sum";
public static final String COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM = "mq_transaction_error_duration_sum";
}
......@@ -21,7 +21,6 @@ package org.skywalking.apm.collector.storage.table.service;
import org.skywalking.apm.collector.core.data.Column;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.core.data.operator.AddOperation;
import org.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.skywalking.apm.collector.core.data.operator.NonOperation;
/**
......@@ -34,11 +33,20 @@ public class ServiceMetric extends Data {
};
private static final Column[] LONG_COLUMNS = {
new Column(ServiceMetricTable.COLUMN_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_ERROR_CALLS, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, new AddOperation()),
new Column(ServiceMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()),
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()),
};
private static final Column[] DOUBLE_COLUMNS = {};
......@@ -63,43 +71,107 @@ public class ServiceMetric extends Data {
setDataInteger(0, serviceId);
}
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,16 +18,12 @@
package org.skywalking.apm.collector.storage.table.service;
import org.skywalking.apm.collector.core.data.CommonTable;
import org.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class ServiceMetricTable extends CommonTable {
public class ServiceMetricTable extends CommonMetricTable {
public static final String TABLE = "service_metric";
public static final String COLUMN_SERVICE_ID = "service_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";
}
......@@ -21,7 +21,6 @@ package org.skywalking.apm.collector.storage.table.service;
import org.skywalking.apm.collector.core.data.Column;
import org.skywalking.apm.collector.core.data.Data;
import org.skywalking.apm.collector.core.data.operator.AddOperation;
import org.skywalking.apm.collector.core.data.operator.CoverOperation;
import org.skywalking.apm.collector.core.data.operator.NonOperation;
/**
......@@ -34,6 +33,8 @@ public class ServiceReferenceMetric 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()),
......@@ -46,7 +47,6 @@ public class ServiceReferenceMetric extends Data {
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(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, new CoverOperation()),
};
private static final Column[] DOUBLE_COLUMNS = {};
......@@ -89,107 +89,107 @@ public class ServiceReferenceMetric extends Data {
setDataInteger(2, behindServiceId);
}
public Long getTransactionCalls() {
public Long getTimeBucket() {
return getDataLong(0);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(0, timeBucket);
}
public Long getTransactionCalls() {
return getDataLong(1);
}
public void setTransactionCalls(Long transactionCalls) {
setDataLong(0, transactionCalls);
setDataLong(1, transactionCalls);
}
public Long getTransactionErrorCalls() {
return getDataLong(1);
return getDataLong(2);
}
public void setTransactionErrorCalls(Long transactionErrorCalls) {
setDataLong(1, transactionErrorCalls);
setDataLong(2, transactionErrorCalls);
}
public Long getTransactionDurationSum() {
return getDataLong(2);
return getDataLong(3);
}
public void setTransactionDurationSum(Long transactionDurationSum) {
setDataLong(2, transactionDurationSum);
setDataLong(3, transactionDurationSum);
}
public Long getTransactionErrorDurationSum() {
return getDataLong(3);
return getDataLong(4);
}
public void setTransactionErrorDurationSum(Long transactionErrorDurationSum) {
setDataLong(3, transactionErrorDurationSum);
setDataLong(4, transactionErrorDurationSum);
}
public Long getBusinessTransactionCalls() {
return getDataLong(4);
return getDataLong(5);
}
public void setBusinessTransactionCalls(Long businessTransactionCalls) {
setDataLong(4, businessTransactionCalls);
setDataLong(5, businessTransactionCalls);
}
public Long getBusinessTransactionErrorCalls() {
return getDataLong(5);
return getDataLong(6);
}
public void setBusinessTransactionErrorCalls(Long businessTransactionErrorCalls) {
setDataLong(5, businessTransactionErrorCalls);
setDataLong(6, businessTransactionErrorCalls);
}
public Long getBusinessTransactionDurationSum() {
return getDataLong(6);
return getDataLong(7);
}
public void setBusinessTransactionDurationSum(Long businessTransactionDurationSum) {
setDataLong(6, businessTransactionDurationSum);
setDataLong(7, businessTransactionDurationSum);
}
public Long getBusinessTransactionErrorDurationSum() {
return getDataLong(7);
return getDataLong(8);
}
public void setBusinessTransactionErrorDurationSum(Long businessTransactionErrorDurationSum) {
setDataLong(7, businessTransactionErrorDurationSum);
setDataLong(8, businessTransactionErrorDurationSum);
}
public Long getMqTransactionCalls() {
return getDataLong(8);
return getDataLong(9);
}
public void setMqTransactionCalls(Long mqTransactionCalls) {
setDataLong(8, mqTransactionCalls);
setDataLong(9, mqTransactionCalls);
}
public Long getMqTransactionErrorCalls() {
return getDataLong(9);
return getDataLong(10);
}
public void setMqTransactionErrorCalls(Long mqTransactionErrorCalls) {
setDataLong(9, mqTransactionErrorCalls);
setDataLong(10, mqTransactionErrorCalls);
}
public Long getMqTransactionDurationSum() {
return getDataLong(10);
return getDataLong(11);
}
public void setMqTransactionDurationSum(Long mqTransactionDurationSum) {
setDataLong(10, mqTransactionDurationSum);
setDataLong(11, mqTransactionDurationSum);
}
public Long getMqTransactionErrorDurationSum() {
return getDataLong(11);
}
public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) {
setDataLong(11, mqTransactionErrorDurationSum);
}
public Long getTimeBucket() {
return getDataLong(12);
}
public void setTimeBucket(Long timeBucket) {
setDataLong(12, timeBucket);
public void setMqTransactionErrorDurationSum(Long mqTransactionErrorDurationSum) {
setDataLong(12, mqTransactionErrorDurationSum);
}
}
......@@ -18,26 +18,14 @@
package org.skywalking.apm.collector.storage.table.service;
import org.skywalking.apm.collector.core.data.CommonTable;
import org.skywalking.apm.collector.storage.table.CommonMetricTable;
/**
* @author peng-yongsheng
*/
public class ServiceReferenceMetricTable extends CommonTable {
public class ServiceReferenceMetricTable extends CommonMetricTable {
public static final String TABLE = "service_reference_metric";
public static final String COLUMN_ENTRY_SERVICE_ID = "entry_service_id";
public static final String COLUMN_FRONT_SERVICE_ID = "front_service_id";
public static final String COLUMN_BEHIND_SERVICE_ID = "behind_service_id";
public static final String COLUMN_TRANSACTION_CALLS = "transaction_calls";
public static final String COLUMN_TRANSACTION_ERROR_CALLS = "transaction_error_calls";
public static final String COLUMN_TRANSACTION_DURATION_SUM = "transaction_duration_sum";
public static final String COLUMN_TRANSACTION_ERROR_DURATION_SUM = "transaction_error_duration_sum";
public static final String COLUMN_BUSINESS_TRANSACTION_CALLS = "business_transaction_calls";
public static final String COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS = "business_transaction_error_calls";
public static final String COLUMN_BUSINESS_TRANSACTION_DURATION_SUM = "business_transaction_duration_sum";
public static final String COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM = "business_transaction_error_duration_sum";
public static final String COLUMN_MQ_TRANSACTION_CALLS = "mq_transaction_calls";
public static final String COLUMN_MQ_TRANSACTION_ERROR_CALLS = "mq_transaction_error_calls";
public static final String COLUMN_MQ_TRANSACTION_DURATION_SUM = "mq_transaction_duration_sum";
public static final String COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM = "mq_transaction_error_duration_sum";
}
......@@ -51,10 +51,22 @@ public class ServiceMetricEsPersistenceDAO extends EsDAO implements IServiceMetr
ServiceMetric serviceMetric = new ServiceMetric(id);
Map<String, Object> source = getResponse.getSource();
serviceMetric.setServiceId(((Number)source.get(ServiceMetricTable.COLUMN_SERVICE_ID)).intValue());
serviceMetric.setCalls(((Number)source.get(ServiceMetricTable.COLUMN_CALLS)).longValue());
serviceMetric.setErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_ERROR_CALLS)).longValue());
serviceMetric.setDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_DURATION_SUM)).longValue());
serviceMetric.setErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM)).longValue());
serviceMetric.setTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue());
serviceMetric.setTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue());
serviceMetric.setTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue());
serviceMetric.setTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue());
serviceMetric.setBusinessTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS)).longValue());
serviceMetric.setBusinessTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS)).longValue());
serviceMetric.setBusinessTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM)).longValue());
serviceMetric.setBusinessTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue());
serviceMetric.setMqTransactionCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS)).longValue());
serviceMetric.setMqTransactionErrorCalls(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS)).longValue());
serviceMetric.setMqTransactionDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM)).longValue());
serviceMetric.setMqTransactionErrorDurationSum(((Number)source.get(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM)).longValue());
serviceMetric.setTimeBucket(((Number)source.get(ServiceMetricTable.COLUMN_TIME_BUCKET)).longValue());
return serviceMetric;
} else {
......@@ -65,10 +77,22 @@ public class ServiceMetricEsPersistenceDAO extends EsDAO implements IServiceMetr
@Override public IndexRequestBuilder prepareBatchInsert(ServiceMetric data) {
Map<String, Object> source = new HashMap<>();
source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId());
source.put(ServiceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ServiceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ServiceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareIndex(ServiceMetricTable.TABLE, data.getId()).setSource(source);
......@@ -77,10 +101,22 @@ public class ServiceMetricEsPersistenceDAO extends EsDAO implements IServiceMetr
@Override public UpdateRequestBuilder prepareBatchUpdate(ServiceMetric data) {
Map<String, Object> source = new HashMap<>();
source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId());
source.put(ServiceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ServiceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ServiceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
return getClient().prepareUpdate(ServiceMetricTable.TABLE, data.getId()).setDoc(source);
......
......@@ -38,10 +38,22 @@ public class ServiceMetricEsTableDefine extends ElasticSearchTableDefine {
@Override public void initialize() {
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_AGG, ElasticSearchColumnDefine.Type.Keyword.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, ElasticSearchColumnDefine.Type.Long.name()));
addColumn(new ElasticSearchColumnDefine(ServiceMetricTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name()));
}
}
......@@ -56,10 +56,22 @@ public class ServiceMetricH2PersistenceDAO extends H2DAO implements IServiceMetr
if (rs.next()) {
ServiceMetric serviceMetric = new ServiceMetric(id);
serviceMetric.setServiceId(rs.getInt(ServiceMetricTable.COLUMN_SERVICE_ID));
serviceMetric.setCalls(rs.getLong(ServiceMetricTable.COLUMN_CALLS));
serviceMetric.setErrorCalls(rs.getLong(ServiceMetricTable.COLUMN_ERROR_CALLS));
serviceMetric.setDurationSum(rs.getLong(ServiceMetricTable.COLUMN_DURATION_SUM));
serviceMetric.setErrorDurationSum(rs.getLong(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM));
serviceMetric.setTransactionCalls(rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_CALLS));
serviceMetric.setTransactionErrorCalls(rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS));
serviceMetric.setTransactionDurationSum(rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM));
serviceMetric.setTransactionErrorDurationSum(rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM));
serviceMetric.setBusinessTransactionCalls(rs.getLong(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS));
serviceMetric.setBusinessTransactionErrorCalls(rs.getLong(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS));
serviceMetric.setBusinessTransactionDurationSum(rs.getLong(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM));
serviceMetric.setBusinessTransactionErrorDurationSum(rs.getLong(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM));
serviceMetric.setMqTransactionCalls(rs.getLong(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS));
serviceMetric.setMqTransactionErrorCalls(rs.getLong(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS));
serviceMetric.setMqTransactionDurationSum(rs.getLong(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM));
serviceMetric.setMqTransactionErrorDurationSum(rs.getLong(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM));
serviceMetric.setTimeBucket(rs.getLong(ServiceMetricTable.COLUMN_TIME_BUCKET));
return serviceMetric;
}
......@@ -75,10 +87,22 @@ public class ServiceMetricH2PersistenceDAO extends H2DAO implements IServiceMetr
Map<String, Object> source = new HashMap<>();
source.put(ServiceMetricTable.COLUMN_ID, data.getId());
source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId());
source.put(ServiceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ServiceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ServiceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchInsertSql(ServiceMetricTable.TABLE, source.keySet());
......@@ -92,10 +116,22 @@ public class ServiceMetricH2PersistenceDAO extends H2DAO implements IServiceMetr
H2SqlEntity entity = new H2SqlEntity();
Map<String, Object> source = new HashMap<>();
source.put(ServiceMetricTable.COLUMN_SERVICE_ID, data.getServiceId());
source.put(ServiceMetricTable.COLUMN_CALLS, data.getCalls());
source.put(ServiceMetricTable.COLUMN_ERROR_CALLS, data.getErrorCalls());
source.put(ServiceMetricTable.COLUMN_DURATION_SUM, data.getDurationSum());
source.put(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, data.getErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, data.getTransactionCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, data.getTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, data.getTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, data.getTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, data.getBusinessTransactionCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, data.getBusinessTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, data.getBusinessTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, data.getBusinessTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, data.getMqTransactionCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, data.getMqTransactionErrorCalls());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, data.getMqTransactionDurationSum());
source.put(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, data.getMqTransactionErrorDurationSum());
source.put(ServiceMetricTable.COLUMN_TIME_BUCKET, data.getTimeBucket());
String sql = SqlBuilder.buildBatchUpdateSql(ServiceMetricTable.TABLE, source.keySet(), ServiceMetricTable.COLUMN_ID);
......
......@@ -34,10 +34,22 @@ public class ServiceMetricH2TableDefine extends H2TableDefine {
@Override public void initialize() {
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_SERVICE_ID, H2ColumnDefine.Type.Int.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_CALLS, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_MQ_TRANSACTION_ERROR_DURATION_SUM, H2ColumnDefine.Type.Bigint.name()));
addColumn(new H2ColumnDefine(ServiceMetricTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name()));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册