peng-yongsheng closed pull request #1022: avoid "by zero" exception when all 
request are error
URL: https://github.com/apache/incubator-skywalking/pull/1022
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 34ae4130c..2b10a5be1 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 void accept(DurationPoint durationPoint) {
         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 410ccd366..102f01ed0 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 InstanceMetricH2UIDAO(H2Client client) {
             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 247283b86..724c62961 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 ServiceMetricH2UIDAO(H2Client client) {
             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 c8f54712b..92e05d1bb 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 Topology getServiceTopology(Step step, int serviceId, 
long startTimeBucke
             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 6ccf59647..c438f71c9 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 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             } 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 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             } 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 @@ Topology 
build(List<IApplicationComponentUIDAO.ApplicationComponent> application
             } 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);
         });
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to