Lines 19-24
Link Here
|
19 |
package org.apache.jmeter.visualizers.backend.graphite; |
19 |
package org.apache.jmeter.visualizers.backend.graphite; |
20 |
|
20 |
|
21 |
import java.text.DecimalFormat; |
21 |
import java.text.DecimalFormat; |
|
|
22 |
import java.util.Arrays; |
22 |
import java.util.HashMap; |
23 |
import java.util.HashMap; |
23 |
import java.util.HashSet; |
24 |
import java.util.HashSet; |
24 |
import java.util.List; |
25 |
import java.util.List; |
Lines 237-269
public class GraphiteBackendListenerClient extends AbstractBackendListenerClient
Link Here
|
237 |
koPercentiles = new HashMap<>(percentilesStringArray.length); |
238 |
koPercentiles = new HashMap<>(percentilesStringArray.length); |
238 |
allPercentiles = new HashMap<>(percentilesStringArray.length); |
239 |
allPercentiles = new HashMap<>(percentilesStringArray.length); |
239 |
DecimalFormat format = new DecimalFormat("0.##"); |
240 |
DecimalFormat format = new DecimalFormat("0.##"); |
240 |
for (int i = 0; i < percentilesStringArray.length; i++) { |
241 |
for (String percentile : percentilesStringArray) { |
241 |
if(!StringUtils.isEmpty(percentilesStringArray[i].trim())) { |
242 |
if (!StringUtils.isEmpty(percentile.trim())) { |
242 |
try { |
243 |
try { |
243 |
Float percentileValue = Float.parseFloat(percentilesStringArray[i].trim()); |
244 |
Float percentileValue = Float.parseFloat(percentile.trim()); |
244 |
okPercentiles.put( |
245 |
okPercentiles.put( |
245 |
METRIC_OK_PERCENTILE_PREFIX+AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
246 |
METRIC_OK_PERCENTILE_PREFIX + AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
246 |
percentileValue); |
247 |
percentileValue); |
247 |
koPercentiles.put( |
248 |
koPercentiles.put( |
248 |
METRIC_KO_PERCENTILE_PREFIX+AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
249 |
METRIC_KO_PERCENTILE_PREFIX + AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
249 |
percentileValue); |
250 |
percentileValue); |
250 |
allPercentiles.put( |
251 |
allPercentiles.put( |
251 |
METRIC_ALL_PERCENTILE_PREFIX+AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
252 |
METRIC_ALL_PERCENTILE_PREFIX + AbstractGraphiteMetricsSender.sanitizeString(format.format(percentileValue)), |
252 |
percentileValue); |
253 |
percentileValue); |
253 |
|
254 |
|
254 |
} catch(Exception e) { |
255 |
} catch (Exception e) { |
255 |
LOGGER.error("Error parsing percentile:'"+percentilesStringArray[i]+"'", e); |
256 |
LOGGER.error("Error parsing percentile:'" + percentile + "'", e); |
256 |
} |
257 |
} |
257 |
} |
258 |
} |
258 |
} |
259 |
} |
259 |
Class<?> clazz = Class.forName(graphiteMetricsSenderClass); |
260 |
Class<?> clazz = Class.forName(graphiteMetricsSenderClass); |
260 |
this.graphiteMetricsManager = (GraphiteMetricsSender) clazz.newInstance(); |
261 |
this.graphiteMetricsManager = (GraphiteMetricsSender) clazz.newInstance(); |
261 |
graphiteMetricsManager.setup(graphiteHost, graphitePort, rootMetricsPrefix); |
262 |
graphiteMetricsManager.setup(graphiteHost, graphitePort, rootMetricsPrefix); |
262 |
String[] samplers = samplersList.split(SEPARATOR); |
263 |
samplersToFilter = new HashSet<>(Arrays.asList(samplersList.split(SEPARATOR))); |
263 |
samplersToFilter = new HashSet<>(); |
|
|
264 |
for (String samplerName : samplers) { |
265 |
samplersToFilter.add(samplerName); |
266 |
} |
267 |
scheduler = Executors.newScheduledThreadPool(MAX_POOL_SIZE); |
264 |
scheduler = Executors.newScheduledThreadPool(MAX_POOL_SIZE); |
268 |
// Don't change this as metrics are per second |
265 |
// Don't change this as metrics are per second |
269 |
this.timerHandle = scheduler.scheduleAtFixedRate(this, ONE_SECOND, ONE_SECOND, TimeUnit.SECONDS); |
266 |
this.timerHandle = scheduler.scheduleAtFixedRate(this, ONE_SECOND, ONE_SECOND, TimeUnit.SECONDS); |