Bug 54333 - Ability to suppress generation of specific samples
Summary: Ability to suppress generation of specific samples
Status: RESOLVED DUPLICATE of bug 61806
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 2.6
Hardware: All All
: P2 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
: 54846 (view as bug list)
Depends on:
Blocks: 54846
  Show dependency tree
 
Reported: 2012-12-20 09:34 UTC by Hari Krishna Dara
Modified: 2019-03-04 10:26 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hari Krishna Dara 2012-12-20 09:34:16 UTC
I would like to request the ability to programmatically mark specific samples to be not recorded. Looking at the code, this could be very straight-forward. E.g., in JMeterThread.process_sample(), call threadContext.getPreviousResult() right before calling notifyListeners() and skip it if is null. This way, a BeanShellAssertion could call ctx.setPreviousResult(null).

BTW, in the documentation at http://jmeter.apache.org/usermanual/test_plan.html#executionorder it indicates that the listeners are skipped if SampleResult is null, but I don't see the check in the code.
Comment 1 Philippe Mouawad 2012-12-23 14:43:45 UTC
(In reply to comment #0)
> I would like to request the ability to programmatically mark specific
> samples to be not recorded. Looking at the code, this could be very
> straight-forward. E.g., in JMeterThread.process_sample(), call
> threadContext.getPreviousResult() right before calling notifyListeners() and
> skip it if is null. This way, a BeanShellAssertion could call
> ctx.setPreviousResult(null).
> 

Currently you can ignore Requests using include/exclude patterns in JMeter Proxy Server. 
Can you clarify why you would want to do that ?

> BTW, in the documentation at
> http://jmeter.apache.org/usermanual/test_plan.html#executionorder it
> indicates that the listeners are skipped if SampleResult is null, but I
> don't see the check in the code.

Can you point to the exact phrase that says that ?
Comment 2 Hari Krishna Dara 2013-01-03 13:24:48 UTC
(In reply to comment #1)
> Currently you can ignore Requests using include/exclude patterns in JMeter
> Proxy Server. 
> Can you clarify why you would want to do that ?

I am not talking about the recording time... but rather at runtime, specifically when using BeanShell elements such as "BeanShell Assertion", "BeanShell Sampler". These are really useful to manipulate the run and go beyond the standard behavior, and I would like that to include the control on whether sample should be recorded or not. Right now, TestAction is the only one that doesn't appear in the results, this is because, it's sample() method unconditionally returns null for result. If I can manipulate the result the way I was suggesting before, or even mark it as to be discarded (e.g., by calling SampleResult.setDiscard(true)), it will provide an option to control their appearance in the final results.

> 
> > BTW, in the documentation at
> > http://jmeter.apache.org/usermanual/test_plan.html#executionorder it
> > indicates that the listeners are skipped if SampleResult is null, but I
> > don't see the check in the code.
> 
> Can you point to the exact phrase that says that ?

I was referring to this: "unless SampleResult is null"

However, I found the code in JMeterThread that checks the result for null and skip the documented steps, so there is nothing wrong here.
Comment 3 Philippe Mouawad 2013-04-14 21:46:22 UTC
*** Bug 54846 has been marked as a duplicate of this bug. ***
Comment 4 Philippe Mouawad 2013-04-14 21:47:04 UTC
Notes from duplocate bug

Sometimes it is desirable to ignore particular samples where you do some setup that is not interesting to be recorded. For example login and similar. Changing layout of test plan often does not look nice.

I think org.apache.jmeter.samplers.SampleResult can be extended to have a property ignore or ignoreByListeners. For scripting samplers one can set that property. And for other samplers the transaction controller can be extended to support marking it's parent sample to be ignored so one can put any samples to be ignored under a transaction controller.

Regards
Comment 5 Sebb 2013-04-16 15:46:04 UTC
Note that a SetUp group should normally be used for this purpose, in which case the samples will not be saved by Listeners in t5he main thread group.

Also only Samplers generate samples, so it is possible to use (e.g.) a BeanShell PreProcessor to do the setup.
Comment 6 Philippe Mouawad 2019-03-04 10:26:48 UTC
This is possible since 4.0 through:

SampleResult#setIgnore()

*** This bug has been marked as a duplicate of bug 61806 ***