Skip to content

Commit 624d0c1

Browse files
authored
Merge pull request #7 from anasoid/add-elapsedduration
add Elapsed duration in second
2 parents d837c09 + e80d856 commit 624d0c1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
4141
* SampleEndTime
4242
* Timestamp
4343
* InjectorHostname
44+
* ElapsedDuration
4445
* Verbose, semi-verbose, error only, and quiet mode
4546
* __debug__ : Send request/response information of all samplers (headers, body, etc.)
4647
* __info__ : Sends all samplers to the ElasticSearch engine, but only sends the headers, body info for the failed samplers.

src/main/java/io/github/delirius325/jmeter/backendlistener/elasticsearch/ElasticSearchMetric.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public Map<String, Object> getMetric(BackendListenerContext context) throws Exce
9797

9898
addAssertions();
9999
addElapsedTime();
100+
addElapsedDuration();
100101
addCustomFields(context);
101102
parseHeadersAsJsonProps(this.allReqHeaders, this.allResHeaders);
102103

@@ -151,6 +152,15 @@ private void addElapsedTime() {
151152
addFilteredJSON("ElapsedTime", elapsedTime.getTime());
152153
}
153154

155+
/**
156+
* This method adds the ElapsedDuration in seconds.
157+
*/
158+
private void addElapsedDuration() {
159+
long elapsed = (System.currentTimeMillis() - JMeterContextService.getTestStartTime()) / 1000;
160+
addFilteredJSON("ElapsedDuration", elapsed);
161+
}
162+
163+
154164
/**
155165
* Methods that add all custom fields added by the user in the Backend Listener's GUI panel
156166
*
@@ -186,7 +196,7 @@ private void addDetails() {
186196

187197
/**
188198
* This method will parse the headers and look for custom variables passed through as header. It can also separate
189-
* all headers into different ElasticSearch document properties by passing "true" This is a work-around for the
199+
* all headers into different ElasticSearch document properties by passing "true" This is a work-around for the
190200
* native behaviour of JMeter, where variables are not accessible within the backend listener.
191201
*
192202
* @param allReqHeaders boolean to determine if the user wants to separate ALL request headers into different ES JSON

0 commit comments

Comments
 (0)