Search in sources :

Example 1 with UserMetric

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);
        }
    }
}
Also used : UserMetric(org.apache.jmeter.visualizers.backend.UserMetric) Matcher(java.util.regex.Matcher) SampleResult(org.apache.jmeter.samplers.SampleResult) SamplerMetric(org.apache.jmeter.visualizers.backend.SamplerMetric)

Example 2 with UserMetric

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();
}
Also used : UserMetric(org.apache.jmeter.visualizers.backend.UserMetric) SamplerMetric(org.apache.jmeter.visualizers.backend.SamplerMetric) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with UserMetric

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);
        }
    }
}
Also used : UserMetric(org.apache.jmeter.visualizers.backend.UserMetric) Matcher(java.util.regex.Matcher) SampleResult(org.apache.jmeter.samplers.SampleResult) SamplerMetric(org.apache.jmeter.visualizers.backend.SamplerMetric)

Example 4 with UserMetric

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();
}
Also used : UserMetric(org.apache.jmeter.visualizers.backend.UserMetric) SamplerMetric(org.apache.jmeter.visualizers.backend.SamplerMetric) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SamplerMetric (org.apache.jmeter.visualizers.backend.SamplerMetric)4 UserMetric (org.apache.jmeter.visualizers.backend.UserMetric)4 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Matcher (java.util.regex.Matcher)2 SampleResult (org.apache.jmeter.samplers.SampleResult)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1