Index: src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java =================================================================== --- src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java (revision 1826463) +++ src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java (working copy) @@ -62,6 +62,8 @@ private int failures; private int hits; private Map errors = new HashMap<>(); + private long sentBytes; + private long receivedBytes; /** @@ -106,6 +108,18 @@ 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 @@ 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 @@ successes = 0; failures = 0; hits = 0; + sentBytes = 0; + receivedBytes = 0; } /** @@ -310,4 +326,18 @@ public Map getErrors() { return errors; } + + /** + * @return the sentBytes + */ + public long getSentBytes() { + return sentBytes; + } + + /** + * @return the receivedBytes + */ + public long getReceivedBytes() { + return receivedBytes; + } } Index: src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java =================================================================== --- src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java (revision 1826463) +++ src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java (working copy) @@ -83,7 +83,10 @@ 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 @@ 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 @@ 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 @@ } } SamplerMetric cumulatedMetrics = getSamplerMetric(CUMULATED_METRICS); - cumulatedMetrics.add(sampleResult); + cumulatedMetrics.add(sampleResult); } } } Index: src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java =================================================================== --- src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java (revision 1827633) +++ src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java (working copy) @@ -76,6 +76,8 @@ 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 @@ */ 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 @@ } private void addMetric(String transaction, int count, + Long sentBytes, Long receivedBytes, String statut, double mean, double minTime, double maxTime, Collection 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 @@ 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 @@ } 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()); } } Index: test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java =================================================================== --- test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java (revision 1826463) +++ test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java (working copy) @@ -55,6 +55,8 @@ 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 @@ 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 @@ 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 @@ 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 @@ result.setErrorCount(success ? 0 : 1); result.sampleStart(); result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME); + result.setSentBytes(1000); + result.setBytes(2000L); return result; } Index: test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java =================================================================== --- test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java (revision 1826463) +++ test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java (working copy) @@ -53,12 +53,16 @@ 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 @@ 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 @@ 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; }