Search code examples
jmeterperformance-testingjmeter-5.0

How to get the parent sample generated by a Transaction Controller in JMeter? SampleResult.getParent() returns null


I have a Thread Group with a Transaction Controller with the "Generate parent sample" checkbox checked and underneath the Transaction Controller is a JSR223 Sampler in which I execute some dummy logging code just to exemplify the problem.

I want to ignore the parent sample and the child sample from all JMeter reporting at runtime.

If, in the JSR223 Sampler I do SampleResult.setIgnore(), then the sample generated by the JSR223 Sampler is no longer logged which is ok, but the Parent transaction generated by the Transaction Controller still gets logged with 0 values. This is observable in the View Results Tree listener.

enter image description here

If I try to get the parent sample, it is null so I can't interact with it in order to ignore it with .setIgnore().

log.info(SampleResult.getParent()) logs null in the log

and

SampleResult.getParent().setIgnore() throws error java.lang.NullPointerException: Cannot invoke method setIgnore() on null object

Is there any way to get and modify the parent sample generated by a Transaction Controller in JMeter?


Solution

  • I don't think it's possible, at least not with JMeter 5.5

    I would recommend using Filter Results Tool to remove the "unwanted" transactions from the .jtl results file.

    Filter Results Tool can be installed using JMeter Plugins Manager.

    Alternatively, i.e. if you're generating a HTML Reporting Dashboard and don't want to include some Transaction Controller(s) into the report basing on a certain condition - you could rename the Transaction Controller and use jmeter.reportgenerator.exporter.html.series_filter and/or jmeter.reportgenerator.sample_filter properties to remove the "unwanted" results from the reporting scope.

    enter image description here