Skip to content

Commit

Permalink
Make service metric contains transaction, business transaction, mq tr…
Browse files Browse the repository at this point in the history
…ansaction.
  • Loading branch information
peng-yongsheng committed Dec 2, 2017
1 parent 6d027a7 commit e64e2c3
Show file tree
Hide file tree
Showing 12 changed files with 307 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public ServiceMetricAggregationWorker(ModuleManager moduleManager) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ private void calculateCost(ServiceReferenceMetric serviceReferenceMetric, long s
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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* @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";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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";
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;

/**
Expand All @@ -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 = {};
Expand All @@ -63,43 +71,107 @@ public void setServiceId(Integer serviceId) {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Loading

0 comments on commit e64e2c3

Please sign in to comment.