Skip to content

Commit

Permalink
ElasticsearchBackendListener: added label option: "verbose" with options
Browse files Browse the repository at this point in the history
always or ifError or never

- `always` send ResponseData always
- `ifError` send ResponseData if some error in sampler
- `never` never send ResponseData

It's useful for optimalization of data sent to Elasticsearch
  • Loading branch information
Radim Daniel Panek committed Sep 22, 2016
1 parent 8ad5b63 commit 969901e
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 22 deletions.
110 changes: 92 additions & 18 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ public void handleSampleResults(List<SampleResult> results,
BackendListenerContext context) {
String indexNameToUse = indexName;
for(SampleResult result : results) {
Map<String,Object> jsonObject = getMap(result);
Map<String,Object> jsonObject = getMap(result, context);
if(dateTimeAppendFormat != null) {
SimpleDateFormat sdf = new SimpleDateFormat(dateTimeAppendFormat);
indexNameToUse = indexName + sdf.format(jsonObject.get(TIMESTAMP));
}
jsonObject.put("testPlanName", context.getParameter("testPlanName"));
jsonObject.put("release", context.getParameter("release"));
jsonObject.put("verbose", context.getParameter("verbose"));
client.prepareIndex(indexNameToUse, sampleType).setSource(jsonObject).execute().actionGet();
}

}

private Map<String, Object> getMap(SampleResult result) {
private Map<String, Object> getMap(SampleResult result, BackendListenerContext context) {
Map<String, Object> map = new HashMap<String, Object>();
String[] sampleLabels = result.getSampleLabel().split(VAR_DELIMITER);
map.put("SampleLabel", sampleLabels[0]);
Expand All @@ -61,7 +62,15 @@ private Map<String, Object> getMap(SampleResult result) {
map.put("RequestHeaders", result.getRequestHeaders());
map.put("ResponseCode", result.getResponseCode());
map.put("ResponseMessage", result.getResponseMessage());
map.put("ResponseData", result.getResponseDataAsString());
if (context.getParameter("verbose").equals("always")) {
map.put("ResponseData", result.getResponseDataAsString());
} else if ( context.getParameter("verbose").equals("ifError") && (result.getErrorCount() > 0) ) {
map.put("ResponseData", result.getResponseDataAsString());
} else if ( context.getParameter("verbose").equals("never") ) {
map.put("ResponseData", "");
} else {
map.put("ResponseData", "");
}
map.put("SubResults", result.getSubResults());
map.put("DataEncoding", result.getDataEncodingWithDefault());
map.put("ThreadName", result.getThreadName());
Expand All @@ -73,7 +82,7 @@ private Map<String, Object> getMap(SampleResult result) {
map.put("Latency", result.getLatency());
map.put("ConnectTime", result.getConnectTime());
map.put("SampleCount", result.getSampleCount());
//map.put("SamplerData", result.getSamplerData());
map.put("SamplerData", result.getSamplerData());
map.put("ErrorCount", result.getErrorCount());
map.put("Bytes", result.getBytes());
map.put("BodySize", result.getBodySize());
Expand Down Expand Up @@ -148,6 +157,7 @@ public Arguments getDefaultParameters() {
arguments.addArgument("runId", "${__UUID()}");
arguments.addArgument("release", "");
arguments.addArgument("testPlanName", "");
arguments.addArgument("verbose", "always|ifError|never");
return arguments;


Expand Down

0 comments on commit 969901e

Please sign in to comment.