public class JtlWriter extends BaseListener
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
JtlWriter.CodeBuilder |
static class |
JtlWriter.SampleStatus |
| Modifier and Type | Field and Description |
|---|---|
protected String |
jtlFile |
protected JtlWriter.SampleStatus |
logOnly |
protected List<String> |
sampleVariables |
protected boolean |
saveActiveThreadCounts |
protected boolean |
saveAssertionFailureMessage |
protected boolean |
saveAssertionResults |
protected boolean |
saveAsXml |
protected boolean |
saveConnectTime |
protected boolean |
saveDataType |
protected boolean |
saveElapsedTime |
protected boolean |
saveEncoding |
protected boolean |
saveFieldNames |
protected boolean |
saveHostname |
protected boolean |
saveIdleTime |
protected boolean |
saveLabel |
protected boolean |
saveLatency |
protected boolean |
saveReceivedByteCount |
protected boolean |
saveRequestHeaders |
protected boolean |
saveResponseCode |
protected boolean |
saveResponseData |
protected boolean |
saveResponseFilename |
protected boolean |
saveResponseHeaders |
protected boolean |
saveResponseMessage |
protected boolean |
saveSampleAndErrorCounts |
protected boolean |
saveSamplerData |
protected boolean |
saveSentByteCount |
protected boolean |
saveSubResults |
protected boolean |
saveSuccess |
protected boolean |
saveThreadName |
protected boolean |
saveTimeStamp |
protected boolean |
saveUrl |
guiClass, name| Constructor and Description |
|---|
JtlWriter(String directoryPath,
String fileName) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.jmeter.testelement.TestElement |
buildTestElement() |
JtlWriter |
logOnly(JtlWriter.SampleStatus status)
Allows filtering which sample results to log according to their status.
|
JtlWriter |
saveAsXml(boolean enabled)
Allows specifying to use XML or CSV format for saving JTL.
|
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.
|
JtlWriter |
withAllFields()
Allows setting to include all fields in XML format.
|
JtlWriter |
withAllFields(boolean enabled)
Allows setting if all or none fields are enabled when saving the JTL.
|
JtlWriter |
withAssertionFailureMessage(boolean enabled)
Allows setting whether or not to include assertion failure message field in generated JTL.
|
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.
|
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.
|
JtlWriter |
withDataType(boolean enabled)
Allows setting whether or not to include response data type (i.e.: binary or text) field in
generated JTL.
|
JtlWriter |
withElapsedTime(boolean enabled)
Allows setting whether or not to include elapsed time (milliseconds spent in each sample) in
generated JTL.
|
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.
|
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.
|
JtlWriter |
withHostname(boolean enabled)
Allows setting whether or not to include host name (name of host that did the sample) field in
generated JTL.
|
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.
|
JtlWriter |
withLabel(boolean enabled)
Allows setting whether or not to include sample label (i.e.: name of the request) field in
generated JTL.
|
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.
|
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.
|
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.
|
JtlWriter |
withResponseCode(boolean enabled)
Allows setting whether or not to include response codes (e.g.: 200) field in generated JTL.
|
JtlWriter |
withResponseData(boolean enabled)
Allows setting whether or not to include response body field in generated JTL.
|
JtlWriter |
withResponseFilename(boolean enabled)
Allows setting whether or not to include response file name (name of file stored by
ResponseFileSaver) field in generated JTL. |
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.
|
JtlWriter |
withResponseMessage(boolean enabled)
Allows setting whether or not to include response message (eg: "OK" for HTTP 200 status code)
in generated JTL.
|
JtlWriter |
withSampleAndErrorCounts(boolean enabled)
Allows setting whether or not to include sample counts (total and error counts) fields in
generated JTL.
|
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.
|
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.
|
JtlWriter |
withSubResults(boolean enabled)
Allows setting whether or not to include sub results (like redirects) entries in generated
JTL.
|
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.
|
JtlWriter |
withThreadName(boolean enabled)
Allows setting whether or not to include thread name field in generated JTL.
|
JtlWriter |
withTimeStamp(boolean enabled)
Allows setting whether or not to include timestamp (epoch when the sample started) field in
generated JTL.
|
JtlWriter |
withUrl(boolean enabled)
Allows setting whether or not to include url field in generated JTL.
|
JtlWriter |
withVariables(String... variables)
Allows specifying JMeter variables to include in generated jtl file.
|
buildConfiguredTestElement, buildTestElementGui, buildTreeUnder, configureTestElement, durationToSeconds, loadBeanProperties, showAndWaitFrameWith, showFrameWith, showInGui, showTestElementGuiclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildTreeUnder, showInGuiprotected String jtlFile
protected JtlWriter.SampleStatus logOnly
protected boolean saveAsXml
protected boolean saveElapsedTime
protected boolean saveResponseMessage
protected boolean saveSuccess
protected boolean saveSentByteCount
protected boolean saveResponseFilename
protected boolean saveEncoding
protected boolean saveIdleTime
protected boolean saveResponseHeaders
protected boolean saveAssertionResults
protected boolean saveFieldNames
protected boolean saveLabel
protected boolean saveThreadName
protected boolean saveAssertionFailureMessage
protected boolean saveActiveThreadCounts
protected boolean saveLatency
protected boolean saveSampleAndErrorCounts
protected boolean saveRequestHeaders
protected boolean saveResponseData
protected boolean saveTimeStamp
protected boolean saveResponseCode
protected boolean saveDataType
protected boolean saveReceivedByteCount
protected boolean saveUrl
protected boolean saveConnectTime
protected boolean saveHostname
protected boolean saveSamplerData
protected boolean saveSubResults
public JtlWriter logOnly(JtlWriter.SampleStatus 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.
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.public JtlWriter withAllFields()
This is just a shorter way of using withAllFields(boolean) with true setting.
withAllFields(boolean)public JtlWriter withAllFields(boolean enabled)
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.
enabled - specifies whether enable or disable all fields.public JtlWriter saveAsXml(boolean enabled)
Take into consideration that some fields (like requestHeaders, responseHeaders, etc.) will only be saved when XML format is used.
enabled - specifies whether enable XML format saving, or disable it (and use CSV). By
default, it is set to false.public JtlWriter withElapsedTime(boolean enabled)
This is usually the most important metric to collect during a performance test, so in general this should be included.
enabled - specifies whether enable or disable inclusion of elapsed time. By default, it is
set to true.public JtlWriter withResponseMessage(boolean enabled)
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.
enabled - specifies whether enable or disable inclusion of response message. By default,
it is set to true.public JtlWriter withSuccess(boolean enabled)
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).
enabled - specifies whether enable or disable inclusion of success field. By default, it
is set to true.public JtlWriter withSentByteCount(boolean enabled)
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.
enabled - specifies whether enable or disable inclusion of sent bytes count. By default,
it is set to true.public JtlWriter withResponseFilename(boolean enabled)
ResponseFileSaver) 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.
enabled - specifies whether enable or disable inclusion of response file name. By default,
it is set to false.public JtlWriter withEncoding(boolean enabled)
enabled - specifies whether enable or disable inclusion of response encoding. By default,
it is set to false.public JtlWriter withIdleTime(boolean enabled)
enabled - specifies whether enable or disable inclusion of idle time. By default, it is
set to true.public JtlWriter withResponseHeaders(boolean enabled)
Note: this field will only be saved if saveAsXml(boolean) is also set to
true.
enabled - specifies whether enable or disable inclusion of response headers. By default,
it is set to false.public JtlWriter withAssertionResults(boolean enabled)
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.
enabled - specifies whether enable or disable inclusion of assertion results. By default,
it is set to true.public JtlWriter withFieldNames(boolean enabled)
Note: this will only be saved if saveAsXml(boolean) is set to false (or not
set, which defaults XML save to false).
enabled - specifies whether enable or disable inclusion of assertion results. By default,
it is set to true.public JtlWriter withLabel(boolean enabled)
In general, you should enable this field to properly identify results to associated samplers.
enabled - specifies whether enable or disable inclusion of sample labels. By default, it
is set to true.public JtlWriter withThreadName(boolean enabled)
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).
enabled - specifies whether enable or disable inclusion of thread name. By default, it is
set to true.public JtlWriter withAssertionFailureMessage(boolean enabled)
This is helpful to trace potential reason of a request being marked as failure.
enabled - specifies whether enable or disable inclusion of assertion failure message. By
default, it is set to true.public JtlWriter withActiveThreadCounts(boolean enabled)
This is helpful to know under how much load (concurrent requests) is the tested service at the moment the request was done.
enabled - specifies whether enable or disable inclusion of active thread counts. By
default, it is set to true.public JtlWriter withLatency(boolean enabled)
This is usually helpful to identify how fast does the tested service takes to answer, taking out the time spent in transferring response data.
enabled - specifies whether enable or disable inclusion of latency time. By default, it is
set to true.public JtlWriter withSampleAndErrorCounts(boolean enabled)
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.
enabled - specifies whether enable or disable inclusion of sample counts. By default, it
is set to false.public JtlWriter withRequestHeaders(boolean enabled)
Note: this field will only be saved if saveAsXml(boolean) is also set to
true.
enabled - specifies whether enable or disable inclusion of request headers. By default, it
is set to false.public JtlWriter withResponseData(boolean enabled)
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
ResponseFileSaver to get a file for each response body.
enabled - specifies whether enable or disable inclusion of response body. By default, it
is set to false.public JtlWriter withTimeStamp(boolean enabled)
enabled - specifies whether enable or disable inclusion of timestamps. By default, it is
set to true.public JtlWriter withResponseCode(boolean enabled)
This field allows to quickly identify different reasons for failure in server (eg: bad request, service temporally unavailable, etc.).
enabled - specifies whether enable or disable inclusion of response codes. By default, it
is set to true.public JtlWriter withDataType(boolean enabled)
enabled - specifies whether enable or disable inclusion of response data types. By
default, it is set to true.public JtlWriter withReceivedByteCount(boolean enabled)
This property is helpful to measure how much load is the network getting and how much information is the tested service generating.
enabled - specifies whether enable or disable inclusion of received bytes counts. By
default, it is set to true.public JtlWriter withUrl(boolean enabled)
This property is helpful when URLs are dynamically generated and may vary for the sample sampler
enabled - specifies whether enable or disable inclusion of urls. By default, it is set to
true.public JtlWriter withConnectTime(boolean enabled)
This is usually helpful to identify issues in network latency when connecting or server load when serving connection requests.
enabled - specifies whether enable or disable inclusion of connect time. By default, it is
set to true.public JtlWriter withHostname(boolean enabled)
This particularly helpful when running JMeter in a distributed fashion to identify which node the sample result is associated to.
enabled - specifies whether enable or disable inclusion of host names. By default, it is
set to false.public JtlWriter withSamplerData(boolean enabled)
Note: this field will only be saved if saveAsXml(boolean) is also set to
true.
enabled - specifies whether enable or disable inclusion of sample data. By default, it is
set to false.public JtlWriter withSubResults(boolean enabled)
enabled - specifies whether enable or disable inclusion of sub results. By default, it is
set to true.public JtlWriter withVariables(String... variables)
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.
variables - names of JMeter variables to include in jtl file.public org.apache.jmeter.testelement.TestElement buildTestElement()
buildTestElement in class BaseTestElementCopyright © 2024. All rights reserved.