skywalking-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pen...@apache.org
Subject [incubator-skywalking] branch master updated: avoid "by zero" exception when all request are error (#1022)
Date Thu, 05 Apr 2018 03:03:06 GMT
This is an automated email from the ASF dual-hosted git repository.

pengys pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 8834f30  avoid "by zero" exception when all request are error (#1022)
8834f30 is described below

commit 8834f30e3a11bf1a64d19651283c891707397bd0
Author: lican <295198088@qq.com>
AuthorDate: Thu Apr 5 11:03:02 2018 +0800

    avoid "by zero" exception when all request are error (#1022)
    
    * avoid "by zero" exception when all request are error
    
    * update pr about "by zero" exception
    
    * update pr about "by zero" exception add 3 file change
    
    * update pr about "by zero" exception add 1 file change
    
    * update pr about "by zero" exception to solution 1
---
 .../apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java       | 4 +---
 .../apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java      | 4 +---
 .../apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java       | 4 +---
 .../skywalking/apm/collector/ui/service/ServiceTopologyService.java | 2 +-
 .../apache/skywalking/apm/collector/ui/service/TopologyBuilder.java | 6 +++---
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
index 34ae413..2b10a5b 100644
--- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java
@@ -73,10 +73,8 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO
{
         for (MultiGetItemResponse response : multiGetResponse.getResponses()) {
             if (response.getResponse().isExists()) {
                 long calls = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue();
-                long errorCalls = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue();
                 long durationSum = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue();
-                long errorDurationSum = ((Number) response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue();
-                trends.add((int) ((durationSum - errorDurationSum) / (calls - errorCalls)));
+                trends.add((int) (durationSum / calls));
             } else {
                 trends.add(0);
             }
diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java
b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java
index 410ccd3..102f01e 100644
--- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java
@@ -90,10 +90,8 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO
             try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) {
                 if (rs.next()) {
                     long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS);
-                    long errorCallTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS);
                     long durationSum = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
-                    long errorDurationSum = rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM);
-                    responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes
- errorCallTimes)));
+                    responseTimeTrends.add((int) (durationSum / callTimes));
                 } else {
                     responseTimeTrends.add(0);
                 }
diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
index 247283b..724c629 100644
--- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
+++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java
@@ -65,10 +65,8 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO
{
             try (ResultSet rs = client.executeQuery(sql, new String[] {id})) {
                 if (rs.next()) {
                     long calls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_CALLS);
-                    long errorCalls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS);
                     long durationSum = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM);
-                    long errorDurationSum = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM);
-                    trends.add((int)((durationSum - errorDurationSum) / (calls - errorCalls)));
+                    trends.add((int) (durationSum / calls));
                 } else {
                     trends.add(0);
                 }
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
index c8f5471..92e05d1 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java
@@ -86,7 +86,7 @@ public class ServiceTopologyService {
             Call call = new Call();
             call.setSource(referenceMetric.getSource());
             call.setTarget(referenceMetric.getTarget());
-            call.setAvgResponseTime((referenceMetric.getDurations() - referenceMetric.getErrorDurations())
/ (referenceMetric.getCalls() - referenceMetric.getErrorCalls()));
+            call.setAvgResponseTime(referenceMetric.getDurations() / referenceMetric.getCalls());
             call.setCallType(components.getOrDefault(serviceNameCacheService.get(referenceMetric.getTarget()).getApplicationId(),
Const.UNKNOWN));
             try {
                 int applicationId = serviceNameCacheService.get(referenceMetric.getTarget()).getApplicationId();
diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
index 6ccf596..c438f71 100644
--- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
+++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java
@@ -97,7 +97,7 @@ class TopologyBuilder {
             } catch (ParseException e) {
                 logger.error(e.getMessage(), e);
             }
-            applicationNode.setAvgResponseTime((applicationMetric.getDurations() - applicationMetric.getErrorDurations())
/ (applicationMetric.getCalls() - applicationMetric.getErrorCalls()));
+            applicationNode.setAvgResponseTime(applicationMetric.getDurations() / applicationMetric.getCalls());
             applicationNode.setApdex(ApdexCalculator.INSTANCE.calculate(applicationMetric.getSatisfiedCount(),
applicationMetric.getToleratingCount(), applicationMetric.getFrustratedCount()));
             applicationNode.setAlarm(false);
             try {
@@ -168,7 +168,7 @@ class TopologyBuilder {
             } catch (ParseException e) {
                 logger.error(e.getMessage(), e);
             }
-            call.setAvgResponseTime((referenceMetric.getDurations() - referenceMetric.getErrorDurations())
/ (referenceMetric.getCalls() - referenceMetric.getErrorCalls()));
+            call.setAvgResponseTime(referenceMetric.getDurations() / referenceMetric.getCalls());
             calls.add(call);
         });
 
@@ -215,7 +215,7 @@ class TopologyBuilder {
             } catch (ParseException e) {
                 logger.error(e.getMessage(), e);
             }
-            call.setAvgResponseTime((referenceMetric.getDurations() - referenceMetric.getErrorDurations())
/ (referenceMetric.getCalls() - referenceMetric.getErrorCalls()));
+            call.setAvgResponseTime(referenceMetric.getDurations() / referenceMetric.getCalls());
             calls.add(call);
         });
 

-- 
To stop receiving notification emails like this one, please contact
pengys@apache.org.

Mime
View raw message