Skip to content

Commit

Permalink
added code to log additional data
Browse files Browse the repository at this point in the history
  • Loading branch information
sfakrudeen78 committed Sep 10, 2019
1 parent 5a809f2 commit 0dc936c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.7
version = '1.2.1'
version = '1.2.2'
def title = 'JMeterInfluxDBListener'

jar {
Expand Down Expand Up @@ -32,7 +32,3 @@ task fatJar(type: Jar) {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public class JMeterInfluxDBBackendListenerClient extends AbstractBackendListener
* Scheduler for periodic metric aggregation.
*/
private ScheduledExecutorService scheduler;

private long testStartTime;


/**
* Name of the test.
Expand Down Expand Up @@ -133,12 +136,42 @@ public void handleSampleResults(List<SampleResult> sampleResults, BackendListene
if ((null != regexForSamplerList && sampleResult.getSampleLabel().matches(regexForSamplerList)) || samplersToFilter.contains(sampleResult.getSampleLabel())) {
Point point = Point.measurement(RequestMeasurement.MEASUREMENT_NAME).time(
System.currentTimeMillis() * ONE_MS_IN_NANOSECONDS + getUniqueNumberForTheSamplerThread(), TimeUnit.NANOSECONDS)

.tag(RequestMeasurement.Tags.REQUEST_NAME, sampleResult.getSampleLabel())
.addField(RequestMeasurement.Fields.ERROR_COUNT, sampleResult.getErrorCount())
.addField(RequestMeasurement.Fields.ERROR_COUNT, sampleResult.getErrorCount())
.addField(RequestMeasurement.Fields.THREAD_NAME, sampleResult.getThreadName())
.tag(RequestMeasurement.Tags.RUN_ID, runId)
.tag(RequestMeasurement.Tags.TEST_NAME, testName)

.addField(RequestMeasurement.Fields.NODE_NAME, nodeName)
.addField(RequestMeasurement.Fields.RESPONSE_SIZE, sampleResult.getBytesAsLong())
.addField(RequestMeasurement.Tags.RESPONSE_CODE, sampleResult.getResponseCode())
.addField(RequestMeasurement.Fields.RESPONSE_LATENCY, sampleResult.getLatency())
.addField(RequestMeasurement.Fields.RESPONSE_CONNECT_TIME, sampleResult.getConnectTime())
.addField(RequestMeasurement.Fields.RESPONSE_TIME, sampleResult.getTime()).build();
influxDB.write(influxDBConfig.getInfluxDatabase(), influxDBConfig.getInfluxRetentionPolicy(), point);
}
}


for(SampleResult sampleResult: allSampleResults) {
getUserMetrics().add(sampleResult);

if ((null != regexForSamplerList && sampleResult.getSampleLabel().matches(regexForSamplerList)) || samplersToFilter.contains(sampleResult.getSampleLabel())) {
Point point = Point.measurement(RequestMeasurement.HISTORY_MEASUTEMENT_NAME).time(
(System.currentTimeMillis() - testStartTime) * ONE_MS_IN_NANOSECONDS + getUniqueNumberForTheSamplerThread(), TimeUnit.NANOSECONDS)

.tag(RequestMeasurement.Tags.REQUEST_NAME, sampleResult.getSampleLabel())
.addField(RequestMeasurement.Fields.ERROR_COUNT, sampleResult.getErrorCount())
.addField(RequestMeasurement.Fields.THREAD_NAME, sampleResult.getThreadName())
.tag(RequestMeasurement.Tags.RUN_ID, runId)
.tag(RequestMeasurement.Tags.TEST_NAME, testName)

.addField(RequestMeasurement.Fields.NODE_NAME, nodeName)
.addField(RequestMeasurement.Fields.RESPONSE_SIZE, sampleResult.getBytesAsLong())
.addField(RequestMeasurement.Tags.RESPONSE_CODE, sampleResult.getResponseCode())
.addField(RequestMeasurement.Fields.RESPONSE_LATENCY, sampleResult.getLatency())
.addField(RequestMeasurement.Fields.RESPONSE_CONNECT_TIME, sampleResult.getConnectTime())
.addField(RequestMeasurement.Fields.RESPONSE_TIME, sampleResult.getTime()).build();
influxDB.write(influxDBConfig.getInfluxDatabase(), influxDBConfig.getInfluxRetentionPolicy(), point);
}
Expand All @@ -165,6 +198,7 @@ public Arguments getDefaultParameters() {

@Override
public void setupTest(BackendListenerContext context) throws Exception {
testStartTime = System.currentTimeMillis();
testName = context.getParameter(KEY_TEST_NAME, "Test");
runId = context.getParameter(KEY_RUN_ID,"R001"); //Will be used to compare performance of R001, R002, etc of 'Test'
randomNumberGenerator = new Random();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface RequestMeasurement {
* Measurement name.
*/
String MEASUREMENT_NAME = "requestsRaw";

String HISTORY_MEASUTEMENT_NAME = "requestsHistoryRaw";

/**
* Tags.
Expand All @@ -34,6 +36,10 @@ public interface Tags {
* Test name field
*/
String TEST_NAME = "testName";

String RESPONSE_CODE = "responseCode";


}

/**
Expand Down Expand Up @@ -62,5 +68,16 @@ public interface Fields {
* Node name field
*/
String NODE_NAME = "nodeName";

String RESPONSE_SIZE ="responseSize";

String RESPONSE_LATENCY="responseLatency";

String RESPONSE_CONNECT_TIME ="responseConnectTime";





}
}

0 comments on commit 0dc936c

Please sign in to comment.