You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2016/03/02 23:24:12 UTC

svn commit: r1733383 - in /jmeter/trunk: docs/images/screenshots/ src/components/org/apache/jmeter/visualizers/backend/graphite/ xdocs/ xdocs/images/screenshots/ xdocs/usermanual/

Author: pmouawad
Date: Wed Mar  2 22:24:12 2016
New Revision: 1733383

URL: http://svn.apache.org/viewvc?rev=1733383&view=rev
Log:
Bug 59099 - Backend listener : Add the possibility to consider samplersList as a Regular Expression
Bugzilla Id: 59099

Modified:
    jmeter/trunk/docs/images/screenshots/backend_listener.png
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/images/screenshots/backend_listener.png
    jmeter/trunk/xdocs/usermanual/component_reference.xml

Modified: jmeter/trunk/docs/images/screenshots/backend_listener.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/docs/images/screenshots/backend_listener.png?rev=1733383&r1=1733382&r2=1733383&view=diff
==============================================================================
Binary files - no diff available.

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java?rev=1733383&r1=1733382&r2=1733383&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java Wed Mar  2 22:24:12 2016
@@ -18,8 +18,8 @@
 
 package org.apache.jmeter.visualizers.backend.graphite;
 
-import java.util.Collections;
 import java.text.DecimalFormat;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -29,6 +29,8 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.jmeter.config.Arguments;
@@ -99,6 +101,7 @@ public class GraphiteBackendListenerClie
     private boolean summaryOnly;
     private String rootMetricsPrefix;
     private String samplersList = ""; //$NON-NLS-1$
+    private boolean useRegexpForSamplersList;
     private Set<String> samplersToFilter;
     private Map<String, Float> okPercentiles;
     private Map<String, Float> koPercentiles;
@@ -110,6 +113,8 @@ public class GraphiteBackendListenerClie
     private ScheduledExecutorService scheduler;
     private ScheduledFuture<?> timerHandle;
     
+    private Pattern pattern;
+
     public GraphiteBackendListenerClient() {
         super();
     }    
@@ -207,12 +212,22 @@ public class GraphiteBackendListenerClie
     @Override
     public void handleSampleResults(List<SampleResult> sampleResults,
             BackendListenerContext context) {
+    	boolean samplersToFilterMatch;
         synchronized (LOCK) {
             for (SampleResult sampleResult : sampleResults) {
                 getUserMetrics().add(sampleResult);
-                if(!summaryOnly && samplersToFilter.contains(sampleResult.getSampleLabel())) {
-                    SamplerMetric samplerMetric = getSamplerMetric(sampleResult.getSampleLabel());
-                    samplerMetric.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);                    
@@ -228,6 +243,7 @@ public class GraphiteBackendListenerClie
         graphitePort = context.getIntParameter("graphitePort", DEFAULT_PLAINTEXT_PROTOCOL_PORT);
         summaryOnly = context.getBooleanParameter("summaryOnly", true);
         samplersList = context.getParameter("samplersList", "");
+        useRegexpForSamplersList = context.getBooleanParameter("useRegexpForSamplersList", false);
         rootMetricsPrefix = context.getParameter("rootMetricsPrefix", DEFAULT_METRICS_PREFIX);
         String percentilesAsString = context.getParameter("percentiles", DEFAULT_METRICS_PREFIX);
         String[]  percentilesStringArray = percentilesAsString.split(SEPARATOR);
@@ -260,9 +276,13 @@ public class GraphiteBackendListenerClie
         Class<?> clazz = Class.forName(graphiteMetricsSenderClass);
         this.graphiteMetricsManager = (GraphiteMetricsSender) clazz.newInstance();
         graphiteMetricsManager.setup(graphiteHost, graphitePort, rootMetricsPrefix);
-        String[] samplers = samplersList.split(SEPARATOR);
-        samplersToFilter = new HashSet<>();
-        Collections.addAll(samplersToFilter, samplers);
+        if (useRegexpForSamplersList) {
+            pattern = Pattern.compile(samplersList);
+        } else {
+            String[] samplers = samplersList.split(SEPARATOR);
+            samplersToFilter = new HashSet<>();
+            Collections.addAll(samplersToFilter, samplers);
+        }
         scheduler = Executors.newScheduledThreadPool(MAX_POOL_SIZE);
         // Don't change this as metrics are per second
         this.timerHandle = scheduler.scheduleAtFixedRate(this, ONE_SECOND, ONE_SECOND, TimeUnit.SECONDS);
@@ -297,6 +317,7 @@ public class GraphiteBackendListenerClie
         arguments.addArgument("rootMetricsPrefix", DEFAULT_METRICS_PREFIX);
         arguments.addArgument("summaryOnly", "true");
         arguments.addArgument("samplersList", "");
+        arguments.addArgument("useRegexpForSamplersList", "false");
         arguments.addArgument("percentiles", DEFAULT_PERCENTILES);
         return arguments;
     }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1733383&r1=1733382&r2=1733383&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Mar  2 22:24:12 2016
@@ -163,6 +163,7 @@ Summary
 <li><bug>58955</bug>Request view http does not correctly display http parameters in multipart/form-data. Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
 <li><bug>55597</bug>View Results Tree: Add a search feature to search in recorded samplers</li>
 <li><bug>59102</bug>View Results Tree: Better default value for "view.results.tree.max_size"</li>
+<li><bug>59099</bug>Backend listener : Add the possibility to consider samplersList as a Regular Expression</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>

Modified: jmeter/trunk/xdocs/images/screenshots/backend_listener.png
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/images/screenshots/backend_listener.png?rev=1733383&r1=1733382&r2=1733383&view=diff
==============================================================================
Binary files - no diff available.

Modified: jmeter/trunk/xdocs/usermanual/component_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/component_reference.xml?rev=1733383&r1=1733382&r2=1733383&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/component_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/component_reference.xml Wed Mar  2 22:24:12 2016
@@ -3525,7 +3525,8 @@ By default, a Graphite implementation is
         <property name="graphitePort" required="Yes">Graphite or InfluxDB (with Graphite plugin enabled) server port, defaults to <code>2003</code>. Note <code>PickleGraphiteMetricsSender</code> (port <code>2004</code>) can only talk to Graphite server.</property>
         <property name="rootMetricsPrefix" required="Yes">Prefix of metrics sent to backend. Defaults to "<code>jmeter</code>."</property>
         <property name="summaryOnly" required="Yes">Only send a summary with no detail. Defaults to <code>true</code>.</property>
-        <property name="samplersList" required="Yes">Semicolon separated list of samplers for which you want to report metrics to backend.</property>
+        <property name="samplersList" required="Yes">Semicolon separated list of samplers if <code>useRegexpForSamplersList=false</code> or a regular expression for which you want to report metrics to backend if <code>useRegexpForSamplersList=true</code>.</property>
+        <property name="useRegexpForSamplersList" required="Yes">Consider samplersList as a regular expression to select the samplers for which you want to report metrics to backend. Defaults to <code>false</code>.</property>
         <property name="percentiles" required="Yes">The percentiles you want to send to backend. List must be semicolon separated.</property>
     </properties>
     <p>Read <a href="realtime-results.html" >this</a> for more details.</p>