jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1828834 - in /jmeter/trunk: src/components/org/apache/jmeter/visualizers/backend/ src/components/org/apache/jmeter/visualizers/backend/graphite/ src/components/org/apache/jmeter/visualizers/backend/influxdb/ test/src/org/apache/jmeter/visu...
Date Tue, 10 Apr 2018 16:59:36 GMT
Author: pmouawad
Date: Tue Apr 10 16:59:36 2018
New Revision: 1828834

URL: http://svn.apache.org/viewvc?rev=1828834&view=rev
Log:
Bug 62276 - InfluxDBBackendListenerClient / GraphiteBackendListenerClient : Add sent and received
bytes to metrics
Contributed by UbikLoadPack
Bugzilla Id: 62276

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
    jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
    jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/realtime-results.xml

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java Tue
Apr 10 16:59:36 2018
@@ -62,6 +62,8 @@ public class SamplerMetric {
     private int failures;
     private int hits;
     private Map<ErrorMetric, Integer> errors = new HashMap<>();
+    private long sentBytes;
+    private long receivedBytes;
 
     
     /**
@@ -106,6 +108,18 @@ public class SamplerMetric {
             koResponsesStats.addValue(time);
         }
         addHits(result);
+        addNetworkData(result);
+    }
+
+    /**
+     * Increment traffic metrics. A Parent sampler cumulates its children metrics.
+     * @param result SampleResult
+     */
+    private void addNetworkData(SampleResult result) {
+        if (!TransactionController.isFromTransactionController(result)) {
+            sentBytes += result.getSentBytes();
+            receivedBytes += result.getBytesAsLong();
+        }
     }
 
     /**
@@ -115,7 +129,7 @@ public class SamplerMetric {
     private void addHits(SampleResult res) {     
         SampleResult[] subResults = res.getSubResults();
         if (!TransactionController.isFromTransactionController(res)) {
-            hits += 1;                 
+            hits += 1;
         }
         for (SampleResult subResult : subResults) {
             addHits(subResult);
@@ -143,6 +157,8 @@ public class SamplerMetric {
         successes = 0;
         failures = 0;
         hits = 0;
+        sentBytes = 0;
+        receivedBytes = 0;
     }
 
     /**
@@ -310,4 +326,18 @@ public class SamplerMetric {
     public Map<ErrorMetric, Integer> getErrors() {
         return errors;
     }
+
+    /**
+     * @return the sentBytes
+     */
+    public long getSentBytes() {
+        return sentBytes;
+    }
+
+    /**
+     * @return the receivedBytes
+     */
+    public long getReceivedBytes() {
+        return receivedBytes;
+    }
 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
Tue Apr 10 16:59:36 2018
@@ -83,7 +83,10 @@ public class GraphiteBackendListenerClie
     private static final String METRIC_KO_PREFIX = "ko"; //$NON-NLS-1$
     private static final String METRIC_ALL_PREFIX = "a"; //$NON-NLS-1$
     private static final String METRIC_HITS_PREFIX = "h"; //$NON-NLS-1$
+    private static final String METRIC_SENT_BYTES_PREFIX = "sb"; //$NON-NLS-1$
+    private static final String METRIC_RECEIVED_BYTES_PREFIX = "rb"; //$NON-NLS-1$
     
+    private static final String METRIC_BYTES = "bytes"; //$NON-NLS-1$
     private static final String METRIC_COUNT = "count"; //$NON-NLS-1$
     private static final String METRIC_MIN_RESPONSE_TIME = "min"; //$NON-NLS-1$
     private static final String METRIC_MAX_RESPONSE_TIME = "max"; //$NON-NLS-1$
@@ -109,6 +112,8 @@ public class GraphiteBackendListenerClie
     private static final String METRIC_ALL_PERCENTILE_PREFIX = METRIC_ALL_PREFIX+METRIC_SEPARATOR+METRIC_PERCENTILE;
 
     private static final String METRIC_ALL_HITS_COUNT        = METRIC_HITS_PREFIX+METRIC_SEPARATOR+METRIC_COUNT;
+    private static final String METRIC_ALL_SENT_BYTES        = METRIC_SENT_BYTES_PREFIX+METRIC_SEPARATOR+METRIC_BYTES;
+    private static final String METRIC_ALL_RECEIVED_BYTES        = METRIC_RECEIVED_BYTES_PREFIX+METRIC_SEPARATOR+METRIC_BYTES;
 
     private static final long SEND_INTERVAL = JMeterUtils.getPropDefault("backend_graphite.send_interval",
1);
     private static final int MAX_POOL_SIZE = 1;
@@ -203,6 +208,10 @@ public class GraphiteBackendListenerClie
                     METRIC_ALL_COUNT, Integer.toString(metric.getTotal()));
             graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
                     METRIC_ALL_HITS_COUNT, Integer.toString(metric.getHits()));
+            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
+                    METRIC_ALL_SENT_BYTES, Long.toString(metric.getSentBytes()));
+            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
+                    METRIC_ALL_RECEIVED_BYTES, Long.toString(metric.getReceivedBytes()));
             if(metric.getSuccesses()>0) {
                 graphiteMetricsManager.addMetric(timestampInSeconds,
                         contextName, METRIC_OK_MIN_RESPONSE_TIME,
@@ -288,7 +297,7 @@ public class GraphiteBackendListenerClie
                     }
                 }
                 SamplerMetric cumulatedMetrics = getSamplerMetric(CUMULATED_METRICS);
-                cumulatedMetrics.add(sampleResult);                    
+                cumulatedMetrics.add(sampleResult);
             }
         }
     }

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java
Tue Apr 10 16:59:36 2018
@@ -76,6 +76,8 @@ public class InfluxdbBackendListenerClie
     private static final String METRIC_AVG = "avg=";
 
     private static final String METRIC_HIT = "hit=";
+    private static final String METRIC_SENT_BYTES = "sb=";
+    private static final String METRIC_RECEIVED_BYTES = "rb=";
     private static final String METRIC_PCT_PREFIX = "pct";
 
     private static final String METRIC_MAX_ACTIVE_THREADS = "maxAT=";
@@ -180,13 +182,13 @@ public class InfluxdbBackendListenerClie
      */
     private void addMetrics(String transaction, SamplerMetric metric) {
         // FOR ALL STATUS
-        addMetric(transaction, metric.getTotal(), TAG_ALL, metric.getAllMean(), metric.getAllMinTime(),
+        addMetric(transaction, metric.getTotal(), metric.getSentBytes(), metric.getReceivedBytes(),
TAG_ALL, metric.getAllMean(), metric.getAllMinTime(),
                 metric.getAllMaxTime(), allPercentiles.values(), metric::getAllPercentile);
         // FOR OK STATUS
-        addMetric(transaction, metric.getSuccesses(), TAG_OK, metric.getOkMean(), metric.getOkMinTime(),
+        addMetric(transaction, metric.getSuccesses(), null, null, TAG_OK, metric.getOkMean(),
metric.getOkMinTime(),
                 metric.getOkMaxTime(), okPercentiles.values(), metric::getOkPercentile);
         // FOR KO STATUS
-        addMetric(transaction, metric.getFailures(), TAG_KO, metric.getKoMean(), metric.getKoMinTime(),
+        addMetric(transaction, metric.getFailures(), null, null, TAG_KO, metric.getKoMean(),
metric.getKoMinTime(),
                 metric.getKoMaxTime(), koPercentiles.values(), metric::getKoPercentile);
 
         metric.getErrors().forEach((error, count) -> addErrorMetric(transaction, error.getResponseCode(),
@@ -209,10 +211,11 @@ public class InfluxdbBackendListenerClie
     }
 
     private void addMetric(String transaction, int count, 
+            Long sentBytes, Long receivedBytes,
             String statut, double mean, double minTime, double maxTime, 
             Collection<Float> pcts, PercentileProvider percentileProvider) {
         if (count > 0) {
-            StringBuilder tag = new StringBuilder(70);
+            StringBuilder tag = new StringBuilder(95);
             tag.append(TAG_APPLICATION).append(application);
             tag.append(TAG_STATUS).append(statut);
             tag.append(TAG_TRANSACTION).append(transaction);
@@ -229,6 +232,12 @@ public class InfluxdbBackendListenerClie
             if (!Double.isNaN(maxTime)) {
                 field.append(',').append(METRIC_MAX).append(maxTime);
             }
+            if(sentBytes != null) {
+                field.append(',').append(METRIC_SENT_BYTES).append(sentBytes);
+            }
+            if(receivedBytes != null) {
+                field.append(',').append(METRIC_RECEIVED_BYTES).append(receivedBytes);
+            }
             for (Float pct : pcts) {
                 field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(
                         percentileProvider.getPercentileValue(pct));
@@ -262,10 +271,11 @@ public class InfluxdbBackendListenerClie
             }
 
             field.append(',').append(METRIC_HIT).append(metric.getHits());
+            field.append(',').append(METRIC_SENT_BYTES).append(metric.getSentBytes());
+            field.append(',').append(METRIC_RECEIVED_BYTES).append(metric.getReceivedBytes());
             for (Float pct : pcts) {
                 field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(Double.toString(metric.getAllPercentile(pct)));
             }
-            field.append(',').append(METRIC_HIT).append(metric.getHits());
             influxdbMetricsManager.addMetric(measurement, tag.toString(), field.toString());
         }
     }

Modified: jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java
Tue Apr 10 16:59:36 2018
@@ -55,6 +55,8 @@ public class SamplerMetricFixedModeTest
         assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
+        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
+        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
 
         // In fixed mode DescriptiveStatistics are not reset, just sliding on a
         // window
@@ -63,6 +65,8 @@ public class SamplerMetricFixedModeTest
         assertEquals("After reset in FIXED mode ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(),
0.001);
         assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.0);
         assertEquals("After reset failure", 0, metric.getHits(), 0.0);
+        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
+        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
     }
 
     @Test
@@ -73,6 +77,8 @@ public class SamplerMetricFixedModeTest
         assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
+        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
+        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
 
         // In fixed mode DescriptiveStatistics are not reset, just sliding on a
         // window
@@ -81,6 +87,8 @@ public class SamplerMetricFixedModeTest
         assertEquals("After reset in FIXED mode  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(),
0.0);
         assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.0);
         assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
+        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
+        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
     }
 
     @Test
@@ -103,6 +111,8 @@ public class SamplerMetricFixedModeTest
         result.setErrorCount(success ? 0 : 1);
         result.sampleStart();
         result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
+        result.setSentBytes(1000);
+        result.setBytes(2000L);
         return result;
     }
 

Modified: jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
(original)
+++ jmeter/trunk/test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java
Tue Apr 10 16:59:36 2018
@@ -53,12 +53,16 @@ public class SamplerMetricTimedModeTest
         assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
+        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
+        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
 
         metric.resetForTimeInterval();
 
         assertEquals("After reset in TIMED mode ok.max", Double.NaN, metric.getOkMaxTime(),
0.0);
         assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(),
0.0);
         assertEquals("After reset failure", 0, metric.getHits(), 0.0);
+        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
+        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
     }
 
     @Test
@@ -69,12 +73,16 @@ public class SamplerMetricTimedModeTest
         assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(),
0.001);
         assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(),
0.001);
         assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
+        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
+        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
 
         metric.resetForTimeInterval();
 
         assertEquals("After reset in TIMED mode  ko.max", Double.NaN, metric.getKoMaxTime(),
0.0);
         assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(),
0.0);
         assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
+        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
+        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
     }
 
     private SampleResult createSampleResult(boolean success) {
@@ -83,6 +91,8 @@ public class SamplerMetricTimedModeTest
         result.setSampleCount(1);
         result.setErrorCount(success ? 0 : 1);
         result.sampleStart();
+        result.setSentBytes(1000);
+        result.setBytes(2000L);
         result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
         return result;
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Apr 10 16:59:36 2018
@@ -108,6 +108,7 @@ this behaviour, set <code>httpclient.res
     <li><bug>62209</bug>InfluxBackendListenerClient: First Assertion Failure
Message must be sent if error code and response code are empty or ok</li>
     <li><bug>62269</bug>Bug 62269 - View Results Tree : Response and Request
Tabs should contains Header and Body tabs. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
     <li><bug>62270</bug>View Results Tree : Allow searching in Request
headers, Response Headers, and Request body. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
+    <li><bug>62276</bug>InfluxDBBackendListenerClient / GraphiteBackendListenerClient
: Add sent and received bytes to metrics. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>

Modified: jmeter/trunk/xdocs/usermanual/realtime-results.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/realtime-results.xml?rev=1828834&r1=1828833&r2=1828834&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/realtime-results.xml (original)
+++ jmeter/trunk/xdocs/usermanual/realtime-results.xml Tue Apr 10 16:59:36 2018
@@ -106,6 +106,10 @@ In this document we will present the con
       <dd>Percentile computed for failed responses of sampler name. There will be one
metric for each calculated value.</dd>
       <dt><code>&lt;rootMetricsPrefix&gt;&lt;samplerName&gt;.a.count</code></dt>
       <dd>Number of responses for sampler name (sum of ok.count and ko.count)</dd>
+      <dt><code>&lt;rootMetricsPrefix&gt;&lt;samplerName&gt;.sb.bytes</code></dt>
+      <dd>Sent Bytes</dd>
+      <dt><code>&lt;rootMetricsPrefix&gt;&lt;samplerName&gt;.rb.bytes</code></dt>
+      <dd>Received Bytes</dd>
       <dt><code>&lt;rootMetricsPrefix&gt;&lt;samplerName&gt;.a.min</code></dt>
       <dd>Min response time for responses of sampler name (min of ok.count and ko.count)</dd>
       <dt><code>&lt;rootMetricsPrefix&gt;&lt;samplerName&gt;.a.max</code></dt>



Mime
View raw message