Class JtlWriter
- java.lang.Object
-
- us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
-
- us.abstracta.jmeter.javadsl.core.listeners.BaseListener
-
- us.abstracta.jmeter.javadsl.core.listeners.JtlWriter
-
- All Implemented Interfaces:
DslTestElement,DslTestPlan.TestPlanChild,DslListener,BaseSampler.SamplerChild,MultiLevelTestElement,BaseThreadGroup.ThreadGroupChild
public class JtlWriter extends BaseListener
Allows to generate a result log file (JTL) with data for each sample for a test plan, thread group or sampler, depending on what level of test plan is added.If jtlWriter is added at testPlan level it will log information about all samples in the test plan, if added at thread group level it will only log samples for samplers contained within it, if added as a sampler child, then only that sampler samples will be logged.
By default, this writer will use JMeter default JTL format, a csv with following fields: timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage, bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect. You can change the format to XML and specify additional (or remove existing ones) fields to store with provided methods.
See JMeter listeners doc for more details on JTL format and settings.
- Since:
- 0.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJtlWriter.CodeBuilderstatic classJtlWriter.SampleStatus
-
Field Summary
Fields Modifier and Type Field Description protected StringjtlFileprotected JtlWriter.SampleStatuslogOnlyprotected List<String>sampleVariablesprotected booleansaveActiveThreadCountsprotected booleansaveAssertionFailureMessageprotected booleansaveAssertionResultsprotected booleansaveAsXmlprotected booleansaveConnectTimeprotected booleansaveDataTypeprotected booleansaveElapsedTimeprotected booleansaveEncodingprotected booleansaveFieldNamesprotected booleansaveHostnameprotected booleansaveIdleTimeprotected booleansaveLabelprotected booleansaveLatencyprotected booleansaveReceivedByteCountprotected booleansaveRequestHeadersprotected booleansaveResponseCodeprotected booleansaveResponseDataprotected booleansaveResponseFilenameprotected booleansaveResponseHeadersprotected booleansaveResponseMessageprotected booleansaveSampleAndErrorCountsprotected booleansaveSamplerDataprotected booleansaveSentByteCountprotected booleansaveSubResultsprotected booleansaveSuccessprotected booleansaveThreadNameprotected booleansaveTimeStampprotected booleansaveUrl-
Fields inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
guiClass, name
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.jmeter.testelement.TestElementbuildTestElement()JtlWriterlogOnly(JtlWriter.SampleStatus status)Allows filtering which sample results to log according to their status.JtlWritersaveAsXml(boolean enabled)Allows specifying to use XML or CSV format for saving JTL.JtlWriterwithActiveThreadCounts(boolean enabled)Allows setting whether or not to include active thread counts (basically, number of concurrent requests, both in the sample thread group, and in all thread groups) fields in generated JTL.JtlWriterwithAllFields()Allows setting to include all fields in XML format.JtlWriterwithAllFields(boolean enabled)Allows setting if all or none fields are enabled when saving the JTL.JtlWriterwithAssertionFailureMessage(boolean enabled)Allows setting whether or not to include assertion failure message field in generated JTL.JtlWriterwithAssertionResults(boolean enabled)Allows setting whether or not to include assertion results (with name, success field, and potential error message) info in generated JTL.JtlWriterwithConnectTime(boolean enabled)Allows setting whether or not to include connect time (milliseconds between the sample started and connection is established to service to start sending request) field in generated JTL.JtlWriterwithDataType(boolean enabled)Allows setting whether or not to include response data type (i.e.: binary or text) field in generated JTL.JtlWriterwithElapsedTime(boolean enabled)Allows setting whether or not to include elapsed time (milliseconds spent in each sample) in generated JTL.JtlWriterwithEncoding(boolean enabled)Allows setting whether or not to include the response encoding (eg: UTF-8, ISO-8859-1, etc.) field in generated JTL.JtlWriterwithFieldNames(boolean enabled)Allows setting whether or not to include assertion results (with name, success field, and potential error message) info in generated JTL.JtlWriterwithHostname(boolean enabled)Allows setting whether or not to include host name (name of host that did the sample) field in generated JTL.JtlWriterwithIdleTime(boolean enabled)Allows setting whether or not to include the Idle time (milliseconds spent in JMeter processing, but not sampling, generally 0) field in generated JTL.JtlWriterwithLabel(boolean enabled)Allows setting whether or not to include sample label (i.e.: name of the request) field in generated JTL.JtlWriterwithLatency(boolean enabled)Allows setting whether or not to include latency time (milliseconds between the sample started and first byte of response is received) field in generated JTL.JtlWriterwithReceivedByteCount(boolean enabled)Allows setting whether or not to include received bytes count (number of bytes sent by server in the response) field in generated JTL.JtlWriterwithRequestHeaders(boolean enabled)Allows setting whether or not to include request headers (eg: HTTP headers like User-Agent and the like) field in generated JTL.JtlWriterwithResponseCode(boolean enabled)Allows setting whether or not to include response codes (e.g.: 200) field in generated JTL.JtlWriterwithResponseData(boolean enabled)Allows setting whether or not to include response body field in generated JTL.JtlWriterwithResponseFilename(boolean enabled)Allows setting whether or not to include response file name (name of file stored byResponseFileSaver) field in generated JTL.JtlWriterwithResponseHeaders(boolean enabled)Allows setting whether or not to include response headers (eg: HTTP headers like Content-Type and the like) field in generated JTL.JtlWriterwithResponseMessage(boolean enabled)Allows setting whether or not to include response message (eg: "OK" for HTTP 200 status code) in generated JTL.JtlWriterwithSampleAndErrorCounts(boolean enabled)Allows setting whether or not to include sample counts (total and error counts) fields in generated JTL.JtlWriterwithSamplerData(boolean enabled)Allows setting whether or not to include sampler data (like cookies, HTTP method, request body and redirection URL) entries in generated JTL.JtlWriterwithSentByteCount(boolean enabled)Allows setting whether or not to include sent bytes count (number of bytes sent to server by request) field in generated JTL.JtlWriterwithSubResults(boolean enabled)Allows setting whether or not to include sub results (like redirects) entries in generated JTL.JtlWriterwithSuccess(boolean enabled)Allows setting whether or not to include success (a boolean indicating if request was success or not) field in generated JTL.JtlWriterwithThreadName(boolean enabled)Allows setting whether or not to include thread name field in generated JTL.JtlWriterwithTimeStamp(boolean enabled)Allows setting whether or not to include timestamp (epoch when the sample started) field in generated JTL.JtlWriterwithUrl(boolean enabled)Allows setting whether or not to include url field in generated JTL.JtlWriterwithVariables(String... variables)Allows specifying JMeter variables to include in generated jtl file.-
Methods inherited from class us.abstracta.jmeter.javadsl.core.testelements.BaseTestElement
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGui
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface us.abstracta.jmeter.javadsl.core.DslTestElement
buildTreeUnder, showInGui
-
-
-
-
Field Detail
-
jtlFile
protected String jtlFile
-
logOnly
protected JtlWriter.SampleStatus logOnly
-
saveAsXml
protected boolean saveAsXml
-
saveElapsedTime
protected boolean saveElapsedTime
-
saveResponseMessage
protected boolean saveResponseMessage
-
saveSuccess
protected boolean saveSuccess
-
saveSentByteCount
protected boolean saveSentByteCount
-
saveResponseFilename
protected boolean saveResponseFilename
-
saveEncoding
protected boolean saveEncoding
-
saveIdleTime
protected boolean saveIdleTime
-
saveResponseHeaders
protected boolean saveResponseHeaders
-
saveAssertionResults
protected boolean saveAssertionResults
-
saveFieldNames
protected boolean saveFieldNames
-
saveLabel
protected boolean saveLabel
-
saveThreadName
protected boolean saveThreadName
-
saveAssertionFailureMessage
protected boolean saveAssertionFailureMessage
-
saveActiveThreadCounts
protected boolean saveActiveThreadCounts
-
saveLatency
protected boolean saveLatency
-
saveSampleAndErrorCounts
protected boolean saveSampleAndErrorCounts
-
saveRequestHeaders
protected boolean saveRequestHeaders
-
saveResponseData
protected boolean saveResponseData
-
saveTimeStamp
protected boolean saveTimeStamp
-
saveResponseCode
protected boolean saveResponseCode
-
saveDataType
protected boolean saveDataType
-
saveReceivedByteCount
protected boolean saveReceivedByteCount
-
saveUrl
protected boolean saveUrl
-
saveConnectTime
protected boolean saveConnectTime
-
saveHostname
protected boolean saveHostname
-
saveSamplerData
protected boolean saveSamplerData
-
saveSubResults
protected boolean saveSubResults
-
-
Method Detail
-
logOnly
public JtlWriter logOnly(JtlWriter.SampleStatus status)
Allows filtering which sample results to log according to their status.This is useful, for example, when you want to have a jtl file with basic information for success sample results, but a more detailed jtl file for the ones that fail.
- Parameters:
status- specifies the status of the sample results to log. When set to null it will log all sample results. By default, it is set to null.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 1.4
-
withAllFields
public JtlWriter withAllFields()
Allows setting to include all fields in XML format.This is just a shorter way of using
withAllFields(boolean)with true setting.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 1.0
- See Also:
withAllFields(boolean)
-
withAllFields
public JtlWriter withAllFields(boolean enabled)
Allows setting if all or none fields are enabled when saving the JTL.If you enable them all, then XML format will be used.
Take into consideration that having a JTL writer with no fields enabled makes no sense. But, you may want to disable all fields to then enable specific ones, and not having to manually disable each of default included fields manually. The same applies when you want most of the fields except for some: in such case you can enable all and then manually disable the ones that you want to exclude.
Also take into consideration that the more fields you add to JTL writer, the more time JMeter will spend on saving the information, and the more disk the file will consume. So, include fields thoughtfully.
- Parameters:
enabled- specifies whether enable or disable all fields.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
saveAsXml
public JtlWriter saveAsXml(boolean enabled)
Allows specifying to use XML or CSV format for saving JTL.Take into consideration that some fields (like requestHeaders, responseHeaders, etc.) will only be saved when XML format is used.
- Parameters:
enabled- specifies whether enable XML format saving, or disable it (and use CSV). By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withElapsedTime
public JtlWriter withElapsedTime(boolean enabled)
Allows setting whether or not to include elapsed time (milliseconds spent in each sample) in generated JTL.This is usually the most important metric to collect during a performance test, so in general this should be included.
- Parameters:
enabled- specifies whether enable or disable inclusion of elapsed time. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withResponseMessage
public JtlWriter withResponseMessage(boolean enabled)
Allows setting whether or not to include response message (eg: "OK" for HTTP 200 status code) in generated JTL.This property is usually handy to trace potential issues, specially the ones that are not standard issues (like HTTPConnectionExceptions) which are not deducible from response code.
- Parameters:
enabled- specifies whether enable or disable inclusion of response message. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withSuccess
public JtlWriter withSuccess(boolean enabled)
Allows setting whether or not to include success (a boolean indicating if request was success or not) field in generated JTL.This property is usually handy to easily identify if a request failed or not (either due to default JMeter logic, or due to some assertion check or post processor alteration).
- Parameters:
enabled- specifies whether enable or disable inclusion of success field. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withSentByteCount
public JtlWriter withSentByteCount(boolean enabled)
Allows setting whether or not to include sent bytes count (number of bytes sent to server by request) field in generated JTL.This property is helpful when requests are dynamically generated or when you want to easily evaluate how much data/load has been transferred to the server.
- Parameters:
enabled- specifies whether enable or disable inclusion of sent bytes count. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withResponseFilename
public JtlWriter withResponseFilename(boolean enabled)
Allows setting whether or not to include response file name (name of file stored byResponseFileSaver) field in generated JTL.This property is helpful when ResponseFileSaver is used to easily trace the request response contents and don't have to include them in JTL file itself.
- Parameters:
enabled- specifies whether enable or disable inclusion of response file name. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withEncoding
public JtlWriter withEncoding(boolean enabled)
Allows setting whether or not to include the response encoding (eg: UTF-8, ISO-8859-1, etc.) field in generated JTL.- Parameters:
enabled- specifies whether enable or disable inclusion of response encoding. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withIdleTime
public JtlWriter withIdleTime(boolean enabled)
Allows setting whether or not to include the Idle time (milliseconds spent in JMeter processing, but not sampling, generally 0) field in generated JTL.- Parameters:
enabled- specifies whether enable or disable inclusion of idle time. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withResponseHeaders
public JtlWriter withResponseHeaders(boolean enabled)
Allows setting whether or not to include response headers (eg: HTTP headers like Content-Type and the like) field in generated JTL.Note: this field will only be saved if
saveAsXml(boolean)is also set to true.- Parameters:
enabled- specifies whether enable or disable inclusion of response headers. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withAssertionResults
public JtlWriter withAssertionResults(boolean enabled)
Allows setting whether or not to include assertion results (with name, success field, and potential error message) info in generated JTL.Note: this will only be saved if
saveAsXml(boolean)is also set to true.This info is handy when tracing why requests are marked as failure and exact reason.
- Parameters:
enabled- specifies whether enable or disable inclusion of assertion results. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withFieldNames
public JtlWriter withFieldNames(boolean enabled)
Allows setting whether or not to include assertion results (with name, success field, and potential error message) info in generated JTL.Note: this will only be saved if
saveAsXml(boolean)is set to false (or not set, which defaults XML save to false).- Parameters:
enabled- specifies whether enable or disable inclusion of assertion results. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withLabel
public JtlWriter withLabel(boolean enabled)
Allows setting whether or not to include sample label (i.e.: name of the request) field in generated JTL.In general, you should enable this field to properly identify results to associated samplers.
- Parameters:
enabled- specifies whether enable or disable inclusion of sample labels. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withThreadName
public JtlWriter withThreadName(boolean enabled)
Allows setting whether or not to include thread name field in generated JTL.This is helpful to identify the requests generated by each thread and allow tracing "correlated" requests (requests that are associated to previous requests in same thread).
- Parameters:
enabled- specifies whether enable or disable inclusion of thread name. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withAssertionFailureMessage
public JtlWriter withAssertionFailureMessage(boolean enabled)
Allows setting whether or not to include assertion failure message field in generated JTL.This is helpful to trace potential reason of a request being marked as failure.
- Parameters:
enabled- specifies whether enable or disable inclusion of assertion failure message. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withActiveThreadCounts
public JtlWriter withActiveThreadCounts(boolean enabled)
Allows setting whether or not to include active thread counts (basically, number of concurrent requests, both in the sample thread group, and in all thread groups) fields in generated JTL.This is helpful to know under how much load (concurrent requests) is the tested service at the moment the request was done.
- Parameters:
enabled- specifies whether enable or disable inclusion of active thread counts. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withLatency
public JtlWriter withLatency(boolean enabled)
Allows setting whether or not to include latency time (milliseconds between the sample started and first byte of response is received) field in generated JTL.This is usually helpful to identify how fast does the tested service takes to answer, taking out the time spent in transferring response data.
- Parameters:
enabled- specifies whether enable or disable inclusion of latency time. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withSampleAndErrorCounts
public JtlWriter withSampleAndErrorCounts(boolean enabled)
Allows setting whether or not to include sample counts (total and error counts) fields in generated JTL.In general sample count will be 1, and error count will be 0 or 1 depending on sample success or failure. But there are some scenarios where these counts might be greater, for example when controllers results are being included.
- Parameters:
enabled- specifies whether enable or disable inclusion of sample counts. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withRequestHeaders
public JtlWriter withRequestHeaders(boolean enabled)
Allows setting whether or not to include request headers (eg: HTTP headers like User-Agent and the like) field in generated JTL.Note: this field will only be saved if
saveAsXml(boolean)is also set to true.- Parameters:
enabled- specifies whether enable or disable inclusion of request headers. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withResponseData
public JtlWriter withResponseData(boolean enabled)
Allows setting whether or not to include response body field in generated JTL.Note: this field will only be saved if
saveAsXml(boolean)is also set to true.This is usually helpful for tracing the response obtained by each sample. Consider using
ResponseFileSaverto get a file for each response body.- Parameters:
enabled- specifies whether enable or disable inclusion of response body. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withTimeStamp
public JtlWriter withTimeStamp(boolean enabled)
Allows setting whether or not to include timestamp (epoch when the sample started) field in generated JTL.- Parameters:
enabled- specifies whether enable or disable inclusion of timestamps. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withResponseCode
public JtlWriter withResponseCode(boolean enabled)
Allows setting whether or not to include response codes (e.g.: 200) field in generated JTL.This field allows to quickly identify different reasons for failure in server (eg: bad request, service temporally unavailable, etc.).
- Parameters:
enabled- specifies whether enable or disable inclusion of response codes. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withDataType
public JtlWriter withDataType(boolean enabled)
Allows setting whether or not to include response data type (i.e.: binary or text) field in generated JTL.- Parameters:
enabled- specifies whether enable or disable inclusion of response data types. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withReceivedByteCount
public JtlWriter withReceivedByteCount(boolean enabled)
Allows setting whether or not to include received bytes count (number of bytes sent by server in the response) field in generated JTL.This property is helpful to measure how much load is the network getting and how much information is the tested service generating.
- Parameters:
enabled- specifies whether enable or disable inclusion of received bytes counts. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withUrl
public JtlWriter withUrl(boolean enabled)
Allows setting whether or not to include url field in generated JTL.This property is helpful when URLs are dynamically generated and may vary for the sample sampler
- Parameters:
enabled- specifies whether enable or disable inclusion of urls. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withConnectTime
public JtlWriter withConnectTime(boolean enabled)
Allows setting whether or not to include connect time (milliseconds between the sample started and connection is established to service to start sending request) field in generated JTL.This is usually helpful to identify issues in network latency when connecting or server load when serving connection requests.
- Parameters:
enabled- specifies whether enable or disable inclusion of connect time. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withHostname
public JtlWriter withHostname(boolean enabled)
Allows setting whether or not to include host name (name of host that did the sample) field in generated JTL.This particularly helpful when running JMeter in a distributed fashion to identify which node the sample result is associated to.
- Parameters:
enabled- specifies whether enable or disable inclusion of host names. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withSamplerData
public JtlWriter withSamplerData(boolean enabled)
Allows setting whether or not to include sampler data (like cookies, HTTP method, request body and redirection URL) entries in generated JTL.Note: this field will only be saved if
saveAsXml(boolean)is also set to true.- Parameters:
enabled- specifies whether enable or disable inclusion of sample data. By default, it is set to false.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withSubResults
public JtlWriter withSubResults(boolean enabled)
Allows setting whether or not to include sub results (like redirects) entries in generated JTL.- Parameters:
enabled- specifies whether enable or disable inclusion of sub results. By default, it is set to true.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.13
-
withVariables
public JtlWriter withVariables(String... variables)
Allows specifying JMeter variables to include in generated jtl file.Warning: variables to sample are test plan wide. This means that if you set them in one jtl writer, they will appear in all jtl writers used in the test plan. Moreover, if you set them in different jtl writers, only variables set on latest one will be considered.
- Parameters:
variables- names of JMeter variables to include in jtl file.- Returns:
- the JtlWriter for further configuration or usage.
- Since:
- 0.22
-
buildTestElement
public org.apache.jmeter.testelement.TestElement buildTestElement()
- Specified by:
buildTestElementin classBaseTestElement
-
-