View | Details | Raw Unified | Return to bug 62276
Collapse All | Expand All

(-)src/components/org/apache/jmeter/visualizers/backend/SamplerMetric.java (-1 / +31 lines)
Lines 62-67 Link Here
62
    private int failures;
62
    private int failures;
63
    private int hits;
63
    private int hits;
64
    private Map<ErrorMetric, Integer> errors = new HashMap<>();
64
    private Map<ErrorMetric, Integer> errors = new HashMap<>();
65
    private long sentBytes;
66
    private long receivedBytes;
65
67
66
    
68
    
67
    /**
69
    /**
Lines 106-111 Link Here
106
            koResponsesStats.addValue(time);
108
            koResponsesStats.addValue(time);
107
        }
109
        }
108
        addHits(result);
110
        addHits(result);
111
        addNetworkData(result);
112
    }
113
114
    /**
115
     * Increment traffic metrics. A Parent sampler cumulates its children metrics.
116
     * @param result SampleResult
117
     */
118
    private void addNetworkData(SampleResult result) {
119
        if (!TransactionController.isFromTransactionController(result)) {
120
            sentBytes += result.getSentBytes();
121
            receivedBytes += result.getBytesAsLong();
122
        }
109
    }
123
    }
110
124
111
    /**
125
    /**
Lines 115-121 Link Here
115
    private void addHits(SampleResult res) {     
129
    private void addHits(SampleResult res) {     
116
        SampleResult[] subResults = res.getSubResults();
130
        SampleResult[] subResults = res.getSubResults();
117
        if (!TransactionController.isFromTransactionController(res)) {
131
        if (!TransactionController.isFromTransactionController(res)) {
118
            hits += 1;                 
132
            hits += 1;
119
        }
133
        }
120
        for (SampleResult subResult : subResults) {
134
        for (SampleResult subResult : subResults) {
121
            addHits(subResult);
135
            addHits(subResult);
Lines 143-148 Link Here
143
        successes = 0;
157
        successes = 0;
144
        failures = 0;
158
        failures = 0;
145
        hits = 0;
159
        hits = 0;
160
        sentBytes = 0;
161
        receivedBytes = 0;
146
    }
162
    }
147
163
148
    /**
164
    /**
Lines 310-313 Link Here
310
    public Map<ErrorMetric, Integer> getErrors() {
326
    public Map<ErrorMetric, Integer> getErrors() {
311
        return errors;
327
        return errors;
312
    }
328
    }
329
330
    /**
331
     * @return the sentBytes
332
     */
333
    public long getSentBytes() {
334
        return sentBytes;
335
    }
336
337
    /**
338
     * @return the receivedBytes
339
     */
340
    public long getReceivedBytes() {
341
        return receivedBytes;
342
    }
313
}
343
}
(-)src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java (-1 / +10 lines)
Lines 83-89 Link Here
83
    private static final String METRIC_KO_PREFIX = "ko"; //$NON-NLS-1$
83
    private static final String METRIC_KO_PREFIX = "ko"; //$NON-NLS-1$
84
    private static final String METRIC_ALL_PREFIX = "a"; //$NON-NLS-1$
84
    private static final String METRIC_ALL_PREFIX = "a"; //$NON-NLS-1$
85
    private static final String METRIC_HITS_PREFIX = "h"; //$NON-NLS-1$
85
    private static final String METRIC_HITS_PREFIX = "h"; //$NON-NLS-1$
86
    private static final String METRIC_SENT_BYTES_PREFIX = "sb"; //$NON-NLS-1$
87
    private static final String METRIC_RECEIVED_BYTES_PREFIX = "rb"; //$NON-NLS-1$
86
    
88
    
89
    private static final String METRIC_BYTES = "bytes"; //$NON-NLS-1$
87
    private static final String METRIC_COUNT = "count"; //$NON-NLS-1$
90
    private static final String METRIC_COUNT = "count"; //$NON-NLS-1$
88
    private static final String METRIC_MIN_RESPONSE_TIME = "min"; //$NON-NLS-1$
91
    private static final String METRIC_MIN_RESPONSE_TIME = "min"; //$NON-NLS-1$
89
    private static final String METRIC_MAX_RESPONSE_TIME = "max"; //$NON-NLS-1$
92
    private static final String METRIC_MAX_RESPONSE_TIME = "max"; //$NON-NLS-1$
Lines 109-114 Link Here
109
    private static final String METRIC_ALL_PERCENTILE_PREFIX = METRIC_ALL_PREFIX+METRIC_SEPARATOR+METRIC_PERCENTILE;
112
    private static final String METRIC_ALL_PERCENTILE_PREFIX = METRIC_ALL_PREFIX+METRIC_SEPARATOR+METRIC_PERCENTILE;
110
113
111
    private static final String METRIC_ALL_HITS_COUNT        = METRIC_HITS_PREFIX+METRIC_SEPARATOR+METRIC_COUNT;
114
    private static final String METRIC_ALL_HITS_COUNT        = METRIC_HITS_PREFIX+METRIC_SEPARATOR+METRIC_COUNT;
115
    private static final String METRIC_ALL_SENT_BYTES        = METRIC_SENT_BYTES_PREFIX+METRIC_SEPARATOR+METRIC_BYTES;
116
    private static final String METRIC_ALL_RECEIVED_BYTES        = METRIC_RECEIVED_BYTES_PREFIX+METRIC_SEPARATOR+METRIC_BYTES;
112
117
113
    private static final long SEND_INTERVAL = JMeterUtils.getPropDefault("backend_graphite.send_interval", 1);
118
    private static final long SEND_INTERVAL = JMeterUtils.getPropDefault("backend_graphite.send_interval", 1);
114
    private static final int MAX_POOL_SIZE = 1;
119
    private static final int MAX_POOL_SIZE = 1;
Lines 203-208 Link Here
203
                    METRIC_ALL_COUNT, Integer.toString(metric.getTotal()));
208
                    METRIC_ALL_COUNT, Integer.toString(metric.getTotal()));
204
            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
209
            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
205
                    METRIC_ALL_HITS_COUNT, Integer.toString(metric.getHits()));
210
                    METRIC_ALL_HITS_COUNT, Integer.toString(metric.getHits()));
211
            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
212
                    METRIC_ALL_SENT_BYTES, Long.toString(metric.getSentBytes()));
213
            graphiteMetricsManager.addMetric(timestampInSeconds, contextName,
214
                    METRIC_ALL_RECEIVED_BYTES, Long.toString(metric.getReceivedBytes()));
206
            if(metric.getSuccesses()>0) {
215
            if(metric.getSuccesses()>0) {
207
                graphiteMetricsManager.addMetric(timestampInSeconds,
216
                graphiteMetricsManager.addMetric(timestampInSeconds,
208
                        contextName, METRIC_OK_MIN_RESPONSE_TIME,
217
                        contextName, METRIC_OK_MIN_RESPONSE_TIME,
Lines 288-294 Link Here
288
                    }
297
                    }
289
                }
298
                }
290
                SamplerMetric cumulatedMetrics = getSamplerMetric(CUMULATED_METRICS);
299
                SamplerMetric cumulatedMetrics = getSamplerMetric(CUMULATED_METRICS);
291
                cumulatedMetrics.add(sampleResult);                    
300
                cumulatedMetrics.add(sampleResult);
292
            }
301
            }
293
        }
302
        }
294
    }
303
    }
(-)src/components/org/apache/jmeter/visualizers/backend/influxdb/InfluxdbBackendListenerClient.java (-5 / +15 lines)
Lines 76-81 Link Here
76
    private static final String METRIC_AVG = "avg=";
76
    private static final String METRIC_AVG = "avg=";
77
77
78
    private static final String METRIC_HIT = "hit=";
78
    private static final String METRIC_HIT = "hit=";
79
    private static final String METRIC_SENT_BYTES = "sb=";
80
    private static final String METRIC_RECEIVED_BYTES = "rb=";
79
    private static final String METRIC_PCT_PREFIX = "pct";
81
    private static final String METRIC_PCT_PREFIX = "pct";
80
82
81
    private static final String METRIC_MAX_ACTIVE_THREADS = "maxAT=";
83
    private static final String METRIC_MAX_ACTIVE_THREADS = "maxAT=";
Lines 180-192 Link Here
180
     */
182
     */
181
    private void addMetrics(String transaction, SamplerMetric metric) {
183
    private void addMetrics(String transaction, SamplerMetric metric) {
182
        // FOR ALL STATUS
184
        // FOR ALL STATUS
183
        addMetric(transaction, metric.getTotal(), TAG_ALL, metric.getAllMean(), metric.getAllMinTime(),
185
        addMetric(transaction, metric.getTotal(), metric.getSentBytes(), metric.getReceivedBytes(), TAG_ALL, metric.getAllMean(), metric.getAllMinTime(),
184
                metric.getAllMaxTime(), allPercentiles.values(), metric::getAllPercentile);
186
                metric.getAllMaxTime(), allPercentiles.values(), metric::getAllPercentile);
185
        // FOR OK STATUS
187
        // FOR OK STATUS
186
        addMetric(transaction, metric.getSuccesses(), TAG_OK, metric.getOkMean(), metric.getOkMinTime(),
188
        addMetric(transaction, metric.getSuccesses(), null, null, TAG_OK, metric.getOkMean(), metric.getOkMinTime(),
187
                metric.getOkMaxTime(), okPercentiles.values(), metric::getOkPercentile);
189
                metric.getOkMaxTime(), okPercentiles.values(), metric::getOkPercentile);
188
        // FOR KO STATUS
190
        // FOR KO STATUS
189
        addMetric(transaction, metric.getFailures(), TAG_KO, metric.getKoMean(), metric.getKoMinTime(),
191
        addMetric(transaction, metric.getFailures(), null, null, TAG_KO, metric.getKoMean(), metric.getKoMinTime(),
190
                metric.getKoMaxTime(), koPercentiles.values(), metric::getKoPercentile);
192
                metric.getKoMaxTime(), koPercentiles.values(), metric::getKoPercentile);
191
193
192
        metric.getErrors().forEach((error, count) -> addErrorMetric(transaction, error.getResponseCode(),
194
        metric.getErrors().forEach((error, count) -> addErrorMetric(transaction, error.getResponseCode(),
Lines 209-218 Link Here
209
    }
211
    }
210
212
211
    private void addMetric(String transaction, int count, 
213
    private void addMetric(String transaction, int count, 
214
            Long sentBytes, Long receivedBytes,
212
            String statut, double mean, double minTime, double maxTime, 
215
            String statut, double mean, double minTime, double maxTime, 
213
            Collection<Float> pcts, PercentileProvider percentileProvider) {
216
            Collection<Float> pcts, PercentileProvider percentileProvider) {
214
        if (count > 0) {
217
        if (count > 0) {
215
            StringBuilder tag = new StringBuilder(70);
218
            StringBuilder tag = new StringBuilder(95);
216
            tag.append(TAG_APPLICATION).append(application);
219
            tag.append(TAG_APPLICATION).append(application);
217
            tag.append(TAG_STATUS).append(statut);
220
            tag.append(TAG_STATUS).append(statut);
218
            tag.append(TAG_TRANSACTION).append(transaction);
221
            tag.append(TAG_TRANSACTION).append(transaction);
Lines 229-234 Link Here
229
            if (!Double.isNaN(maxTime)) {
232
            if (!Double.isNaN(maxTime)) {
230
                field.append(',').append(METRIC_MAX).append(maxTime);
233
                field.append(',').append(METRIC_MAX).append(maxTime);
231
            }
234
            }
235
            if(sentBytes != null) {
236
                field.append(',').append(METRIC_SENT_BYTES).append(sentBytes);
237
            }
238
            if(receivedBytes != null) {
239
                field.append(',').append(METRIC_RECEIVED_BYTES).append(receivedBytes);
240
            }
232
            for (Float pct : pcts) {
241
            for (Float pct : pcts) {
233
                field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(
242
                field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(
234
                        percentileProvider.getPercentileValue(pct));
243
                        percentileProvider.getPercentileValue(pct));
Lines 262-271 Link Here
262
            }
271
            }
263
272
264
            field.append(',').append(METRIC_HIT).append(metric.getHits());
273
            field.append(',').append(METRIC_HIT).append(metric.getHits());
274
            field.append(',').append(METRIC_SENT_BYTES).append(metric.getSentBytes());
275
            field.append(',').append(METRIC_RECEIVED_BYTES).append(metric.getReceivedBytes());
265
            for (Float pct : pcts) {
276
            for (Float pct : pcts) {
266
                field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(Double.toString(metric.getAllPercentile(pct)));
277
                field.append(',').append(METRIC_PCT_PREFIX).append(pct).append('=').append(Double.toString(metric.getAllPercentile(pct)));
267
            }
278
            }
268
            field.append(',').append(METRIC_HIT).append(metric.getHits());
269
            influxdbMetricsManager.addMetric(measurement, tag.toString(), field.toString());
279
            influxdbMetricsManager.addMetric(measurement, tag.toString(), field.toString());
270
        }
280
        }
271
    }
281
    }
(-)test/src/org/apache/jmeter/visualizers/backend/SamplerMetricFixedModeTest.java (+10 lines)
Lines 55-60 Link Here
55
        assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
55
        assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
56
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
56
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
57
        assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
57
        assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
58
        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
59
        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
58
60
59
        // In fixed mode DescriptiveStatistics are not reset, just sliding on a
61
        // In fixed mode DescriptiveStatistics are not reset, just sliding on a
60
        // window
62
        // window
Lines 63-68 Link Here
63
        assertEquals("After reset in FIXED mode ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
65
        assertEquals("After reset in FIXED mode ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
64
        assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
66
        assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
65
        assertEquals("After reset failure", 0, metric.getHits(), 0.0);
67
        assertEquals("After reset failure", 0, metric.getHits(), 0.0);
68
        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
69
        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
66
    }
70
    }
67
71
68
    @Test
72
    @Test
Lines 73-78 Link Here
73
        assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
77
        assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
74
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
78
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
75
        assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
79
        assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
80
        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
81
        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
76
82
77
        // In fixed mode DescriptiveStatistics are not reset, just sliding on a
83
        // In fixed mode DescriptiveStatistics are not reset, just sliding on a
78
        // window
84
        // window
Lines 81-86 Link Here
81
        assertEquals("After reset in FIXED mode  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.0);
87
        assertEquals("After reset in FIXED mode  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.0);
82
        assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
88
        assertEquals("After reset in FIXED mode all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.0);
83
        assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
89
        assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
90
        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
91
        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
84
    }
92
    }
85
93
86
    @Test
94
    @Test
Lines 103-108 Link Here
103
        result.setErrorCount(success ? 0 : 1);
111
        result.setErrorCount(success ? 0 : 1);
104
        result.sampleStart();
112
        result.sampleStart();
105
        result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
113
        result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
114
        result.setSentBytes(1000);
115
        result.setBytes(2000L);
106
        return result;
116
        return result;
107
    }
117
    }
108
118
(-)test/src/org/apache/jmeter/visualizers/backend/SamplerMetricTimedModeTest.java (+10 lines)
Lines 53-64 Link Here
53
        assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
53
        assertEquals("Before reset  ok.max", DEFAULT_ELAPSED_TIME, metric.getOkMaxTime(), 0.001);
54
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
54
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
55
        assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
55
        assertEquals("Before reset failure", 1, metric.getHits(), 0.0);
56
        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
57
        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
56
58
57
        metric.resetForTimeInterval();
59
        metric.resetForTimeInterval();
58
60
59
        assertEquals("After reset in TIMED mode ok.max", Double.NaN, metric.getOkMaxTime(), 0.0);
61
        assertEquals("After reset in TIMED mode ok.max", Double.NaN, metric.getOkMaxTime(), 0.0);
60
        assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
62
        assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
61
        assertEquals("After reset failure", 0, metric.getHits(), 0.0);
63
        assertEquals("After reset failure", 0, metric.getHits(), 0.0);
64
        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
65
        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
62
    }
66
    }
63
67
64
    @Test
68
    @Test
Lines 69-80 Link Here
69
        assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
73
        assertEquals("Before reset  ko.max", DEFAULT_ELAPSED_TIME, metric.getKoMaxTime(), 0.001);
70
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
74
        assertEquals("Before reset all.max", DEFAULT_ELAPSED_TIME, metric.getAllMaxTime(), 0.001);
71
        assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
75
        assertEquals("Before reset failure", 1, metric.getFailures(), 0.0);
76
        assertEquals("Before reset sent bytes", 1000, metric.getSentBytes(), 0.0);
77
        assertEquals("Before reset received bytes", 2000, metric.getReceivedBytes(), 0.0);
72
78
73
        metric.resetForTimeInterval();
79
        metric.resetForTimeInterval();
74
80
75
        assertEquals("After reset in TIMED mode  ko.max", Double.NaN, metric.getKoMaxTime(), 0.0);
81
        assertEquals("After reset in TIMED mode  ko.max", Double.NaN, metric.getKoMaxTime(), 0.0);
76
        assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
82
        assertEquals("After reset in TIMED mode all.max", Double.NaN, metric.getAllMaxTime(), 0.0);
77
        assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
83
        assertEquals("After reset failure", 0, metric.getFailures(), 0.001);
84
        assertEquals("After reset sent bytes", 0, metric.getSentBytes(), 0.0);
85
        assertEquals("After reset received bytes", 0, metric.getReceivedBytes(), 0.0);
78
    }
86
    }
79
87
80
    private SampleResult createSampleResult(boolean success) {
88
    private SampleResult createSampleResult(boolean success) {
Lines 83-88 Link Here
83
        result.setSampleCount(1);
91
        result.setSampleCount(1);
84
        result.setErrorCount(success ? 0 : 1);
92
        result.setErrorCount(success ? 0 : 1);
85
        result.sampleStart();
93
        result.sampleStart();
94
        result.setSentBytes(1000);
95
        result.setBytes(2000L);
86
        result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
96
        result.setEndTime(result.getStartTime() + DEFAULT_ELAPSED_TIME);
87
        return result;
97
        return result;
88
    }
98
    }

Return to bug 62276