use of org.apache.jmeter.visualizers.backend.UserMetric in project jmeter by apache.
the class InfluxdbBackendListenerClient method handleSampleResults.
@Override
public void handleSampleResults(List<SampleResult> sampleResults, BackendListenerContext context) {
synchronized (LOCK) {
UserMetric userMetrics = getUserMetrics();
for (SampleResult sampleResult : sampleResults) {
userMetrics.add(sampleResult);
Matcher matcher = samplersToFilter.matcher(sampleResult.getSampleLabel());
if (!summaryOnly && (matcher.find())) {
SamplerMetric samplerMetric = getSamplerMetricInfluxdb(sampleResult.getSampleLabel());
samplerMetric.add(sampleResult);
}
SamplerMetric cumulatedMetrics = getSamplerMetricInfluxdb(CUMULATED_METRICS);
cumulatedMetrics.add(sampleResult);
}
}
}
use of org.apache.jmeter.visualizers.backend.UserMetric in project jmeter by apache.
the class InfluxdbBackendListenerClient method sendMetrics.
/**
* Send metrics
*/
protected void sendMetrics() {
synchronized (LOCK) {
for (Map.Entry<String, SamplerMetric> entry : getMetricsInfluxdbPerSampler().entrySet()) {
SamplerMetric metric = entry.getValue();
if (entry.getKey().equals(CUMULATED_METRICS)) {
addCumulatedMetrics(metric);
} else {
addMetrics(AbstractInfluxdbMetricsSender.tagToStringValue(entry.getKey()), metric);
}
// We are computing on interval basis so cleanup
metric.resetForTimeInterval();
}
}
UserMetric userMetrics = getUserMetrics();
// For JMETER context
StringBuilder tag = new StringBuilder(60);
tag.append(TAG_APPLICATION).append(application);
tag.append(TAG_TRANSACTION).append("internal");
StringBuilder field = new StringBuilder(80);
field.append(METRIC_MIN_ACTIVE_THREADS).append(userMetrics.getMinActiveThreads()).append(",");
field.append(METRIC_MAX_ACTIVE_THREADS).append(userMetrics.getMaxActiveThreads()).append(",");
field.append(METRIC_MEAN_ACTIVE_THREADS).append(userMetrics.getMeanActiveThreads()).append(",");
field.append(METRIC_STARTED_THREADS).append(userMetrics.getStartedThreads()).append(",");
field.append(METRIC_ENDED_THREADS).append(userMetrics.getFinishedThreads());
influxdbMetricsManager.addMetric(measurement, tag.toString(), field.toString());
influxdbMetricsManager.writeAndSendMetrics();
}
use of org.apache.jmeter.visualizers.backend.UserMetric in project jmeter by apache.
the class GraphiteBackendListenerClient method handleSampleResults.
@Override
public void handleSampleResults(List<SampleResult> sampleResults, BackendListenerContext context) {
boolean samplersToFilterMatch;
synchronized (LOCK) {
UserMetric userMetrics = getUserMetrics();
for (SampleResult sampleResult : sampleResults) {
userMetrics.add(sampleResult);
if (!summaryOnly) {
if (useRegexpForSamplersList) {
Matcher matcher = pattern.matcher(sampleResult.getSampleLabel());
samplersToFilterMatch = matcher.matches();
} else {
samplersToFilterMatch = samplersToFilter.contains(sampleResult.getSampleLabel());
}
if (samplersToFilterMatch) {
SamplerMetric samplerMetric = getSamplerMetric(sampleResult.getSampleLabel());
samplerMetric.add(sampleResult);
}
}
SamplerMetric cumulatedMetrics = getSamplerMetric(CUMULATED_METRICS);
cumulatedMetrics.add(sampleResult);
}
}
}
use of org.apache.jmeter.visualizers.backend.UserMetric in project jmeter by apache.
the class GraphiteBackendListenerClient method sendMetrics.
/**
* Send metrics to Graphite
*/
protected void sendMetrics() {
// Need to convert millis to seconds for Graphite
long timestampInSeconds = TimeUnit.SECONDS.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
synchronized (LOCK) {
for (Map.Entry<String, SamplerMetric> entry : getMetricsPerSampler().entrySet()) {
final String key = entry.getKey();
final SamplerMetric metric = entry.getValue();
if (key.equals(CUMULATED_METRICS)) {
addMetrics(timestampInSeconds, ALL_CONTEXT_NAME, metric);
} else {
addMetrics(timestampInSeconds, AbstractGraphiteMetricsSender.sanitizeString(key), metric);
}
// We are computing on interval basis so cleanup
metric.resetForTimeInterval();
}
}
UserMetric userMetric = getUserMetrics();
graphiteMetricsManager.addMetric(timestampInSeconds, TEST_CONTEXT_NAME, METRIC_MIN_ACTIVE_THREADS, Integer.toString(userMetric.getMinActiveThreads()));
graphiteMetricsManager.addMetric(timestampInSeconds, TEST_CONTEXT_NAME, METRIC_MAX_ACTIVE_THREADS, Integer.toString(userMetric.getMaxActiveThreads()));
graphiteMetricsManager.addMetric(timestampInSeconds, TEST_CONTEXT_NAME, METRIC_MEAN_ACTIVE_THREADS, Integer.toString(userMetric.getMeanActiveThreads()));
graphiteMetricsManager.addMetric(timestampInSeconds, TEST_CONTEXT_NAME, METRIC_STARTED_THREADS, Integer.toString(userMetric.getStartedThreads()));
graphiteMetricsManager.addMetric(timestampInSeconds, TEST_CONTEXT_NAME, METRIC_FINISHED_THREADS, Integer.toString(userMetric.getFinishedThreads()));
graphiteMetricsManager.writeAndSendMetrics();
}
Aggregations