Skip to content

Commit aebdee7

Browse files
author
Dušan Markovič
committed
fix multiple potential bugs, enhance logging data, set version to SNAPSHOT
1 parent 4a265bd commit aebdee7

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
1515
* Bulk requests
1616
* By making bulk requests, there are practically no impacts on the performance of the tests themselves.
1717
* Filters
18-
* Only send the samples you want by using Filters! Simply type them as follows in the appropriate field : ``filter1;filter2;filter3`` or ``sampleLabel_must_contain_this``.
18+
* Only send the samples you want by using Filters! Simply type them as follows in the field ``es.sample.filter`` : ``filter1;filter2;filter3`` or ``sampleLabel_must_contain_this``.
1919
* Specific fields ```field1;field2;field3`
2020
* Specify fields that you want to send to ElasticSearch (possible fields below)
2121
* AllThreads
@@ -56,7 +56,7 @@ JMeter ElasticSearch Backend Listener is a JMeter plugin enabling you to send te
5656
<dependency>
5757
<groupId>io.github.delirius325</groupId>
5858
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
59-
<version>2.6.10</version>
59+
<version>2.6.10-SNAPSHOT</version>
6060
</dependency>
6161
```
6262

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>io.github.delirius325</groupId>
77
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
8-
<version>2.6.10</version>
8+
<version>2.6.10-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<name>jmeter.backendlistener.elasticsearch</name>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,19 @@ private void addElapsedTime() {
155155
*/
156156
private void addCustomFields(BackendListenerContext context) {
157157
Iterator<String> pluginParameters = context.getParameterNamesIterator();
158+
String parameter;
158159
while (pluginParameters.hasNext()) {
159160
String parameterName = pluginParameters.next();
160161

161-
if (!parameterName.startsWith("es.") && !context.getParameter(parameterName).trim().equals("")) {
162-
String parameter = context.getParameter(parameterName).trim();
162+
if (!parameterName.startsWith("es.") && context.containsParameter(parameterName)
163+
&& !"".equals(parameter = context.getParameter(parameterName).trim())) {
163164

164165
try {
165166
addFilteredJSON(parameterName, Long.parseLong(parameter));
166-
} catch (Exception e) {
167+
} catch (NumberFormatException e) {
167168
if (logger.isDebugEnabled())
168-
logger.debug("Cannot convert custom field to number");
169-
addFilteredJSON(parameterName, context.getParameter(parameterName).trim());
169+
logger.debug("Cannot convert custom field to number [name={}, value={}]]", parameterName, parameter);
170+
addFilteredJSON(parameterName, parameter);
170171
}
171172
}
172173
}
@@ -217,7 +218,7 @@ private void parseHeadersAsJsonProps(boolean allReqHeaders, boolean allResHeader
217218

218219
// if not all res/req headers and header contains special X-tag
219220
if (!allReqHeaders && !allResHeaders && header.length > 1) {
220-
if (header[0].startsWith("X-es-backend")) {
221+
if (header[0].startsWith("X-es-backend-")) {
221222
this.json.put(header[0].replaceAll("X-es-backend-", "").trim(), header[1].trim());
222223
}
223224
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public int getElasticSearchVersion() {
104104
try {
105105
Response response = this.client.performRequest(setAuthorizationHeader(request));
106106
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK && logger.isErrorEnabled()) {
107-
logger.error("Unable to perform request to ElasticSearch engine", this.esIndex);
107+
logger.error("Unable to perform request to ElasticSearch engine for index {}. Response status: {}",
108+
this.esIndex, response.getStatusLine().toString());
108109
}else {
109110
String responseBody = EntityUtils.toString(response.getEntity());
110111
JSONObject elasticSearchConfig = new JSONObject(responseBody);
@@ -153,7 +154,10 @@ public void sendRequest(int elasticSearchVersionPrefix) {
153154
Response response = this.client.performRequest(setAuthorizationHeader(request));
154155

155156
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK && logger.isErrorEnabled()) {
156-
logger.error("ElasticSearch Backend Listener failed to write results for index {}", this.esIndex);
157+
logger.error("ElasticSearch Backend Listener failed to write results for index {}. Response status: {}",
158+
this.esIndex, response.getStatusLine().toString());
159+
} else {
160+
logger.debug("ElasticSearch Backend Listener has successfully written results for index {}", this.esIndex);
157161
}
158162
} catch (Exception e) {
159163
if (logger.isErrorEnabled()) {

0 commit comments

Comments
 (0)