Skip to content

Commit

Permalink
Merge pull request NovatecConsulting#20 from eostermueller/master
Browse files Browse the repository at this point in the history
influxdb tag/field tweaks to support new comparison feature
  • Loading branch information
AlexanderWert authored Apr 9, 2018
2 parents 41295c3 + c73724d commit 2370d58
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 15 deletions.
4 changes: 2 additions & 2 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'
version = '1.2x'
def title = 'JMeterInfluxDBListener'

jar {
Expand Down Expand Up @@ -35,4 +35,4 @@ task fatJar(type: Jar) {

task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
}
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class JMeterInfluxDBBackendListenerClient extends AbstractBackendListener
*/
private static final String KEY_USE_REGEX_FOR_SAMPLER_LIST = "useRegexForSamplerList";
private static final String KEY_TEST_NAME = "testName";
private static final String KEY_RUN_ID = "runId";
private static final String KEY_NODE_NAME = "nodeName";
private static final String KEY_SAMPLERS_LIST = "samplersList";
private static final String KEY_RECORD_SUB_SAMPLES = "recordSubSamples";
Expand All @@ -64,6 +65,12 @@ public class JMeterInfluxDBBackendListenerClient extends AbstractBackendListener
*/
private String testName;

/**
* A unique identifier for a single execution (aka 'run') of a load test.
* In a CI/CD automated performance test, a Jenkins or Bamboo build id would be a good value for this.
*/
private String runId;

/**
* Name of the name
*/
Expand Down Expand Up @@ -126,10 +133,11 @@ 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())
.tag(RequestMeasurement.Tags.REQUEST_NAME, sampleResult.getSampleLabel())
.addField(RequestMeasurement.Fields.ERROR_COUNT, sampleResult.getErrorCount())
.addField(RequestMeasurement.Fields.THREAD_NAME, sampleResult.getThreadName())
.addField(RequestMeasurement.Fields.TEST_NAME, testName)
.tag(RequestMeasurement.Tags.RUN_ID, runId)
.tag(RequestMeasurement.Tags.TEST_NAME, testName)
.addField(RequestMeasurement.Fields.NODE_NAME, nodeName)
.addField(RequestMeasurement.Fields.RESPONSE_TIME, sampleResult.getTime()).build();
influxDB.write(influxDBConfig.getInfluxDatabase(), influxDBConfig.getInfluxRetentionPolicy(), point);
Expand All @@ -142,6 +150,7 @@ public Arguments getDefaultParameters() {
Arguments arguments = new Arguments();
arguments.addArgument(KEY_TEST_NAME, "Test");
arguments.addArgument(KEY_NODE_NAME, "Test-Node");
arguments.addArgument(KEY_RUN_ID, "R001");
arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_HOST, "localhost");
arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_PORT, Integer.toString(InfluxDBConfig.DEFAULT_PORT));
arguments.addArgument(InfluxDBConfig.KEY_INFLUX_DB_USER, "");
Expand All @@ -157,6 +166,7 @@ public Arguments getDefaultParameters() {
@Override
public void setupTest(BackendListenerContext context) throws Exception {
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();
nodeName = context.getParameter(KEY_NODE_NAME, "Test-Node");

Expand All @@ -168,7 +178,8 @@ public void setupTest(BackendListenerContext context) throws Exception {
Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED)
.tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName)
.addField(TestStartEndMeasurement.Fields.TEST_NAME, testName)
.tag(TestStartEndMeasurement.Tags.TEST_NAME, testName)
.addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1")
.build());

parseSamplers(context);
Expand All @@ -192,7 +203,9 @@ public void teardownTest(BackendListenerContext context) throws Exception {
Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED)
.tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName)
.addField(TestStartEndMeasurement.Fields.TEST_NAME, testName)
.tag(TestStartEndMeasurement.Tags.RUN_ID, runId)
.tag(TestStartEndMeasurement.Tags.TEST_NAME, testName)
.addField(TestStartEndMeasurement.Fields.PLACEHOLDER,"1")
.build());

influxDB.disableBatch();
Expand Down Expand Up @@ -264,6 +277,8 @@ private void addVirtualUsersMetrics(int minActiveThreads, int meanActiveThreads,
builder.addField(VirtualUsersMeasurement.Fields.STARTED_THREADS, startedThreads);
builder.addField(VirtualUsersMeasurement.Fields.FINISHED_THREADS, finishedThreads);
builder.tag(VirtualUsersMeasurement.Tags.NODE_NAME, nodeName);
builder.tag(VirtualUsersMeasurement.Tags.TEST_NAME, testName);
builder.tag(VirtualUsersMeasurement.Tags.RUN_ID, runId);
influxDB.write(influxDBConfig.getInfluxDatabase(), influxDBConfig.getInfluxRetentionPolicy(), builder.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void setupTest(BackendListenerContext context) throws Exception {
exportFileWriter = new BufferedWriter(new FileWriter(exportFile));

Point startPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED).addField(TestStartEndMeasurement.Fields.TEST_NAME, testName).build();
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build();
exportFileWriter.append(startPoint.lineProtocol());
exportFileWriter.newLine();

Expand All @@ -150,7 +150,7 @@ public void teardownTest(BackendListenerContext context) throws Exception {

addVirtualUsersMetrics(0, 0, 0, 0, JMeterContextService.getThreadCounts().finishedThreads);
Point endPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED).addField(TestStartEndMeasurement.Fields.TEST_NAME, testName).build();
.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build();

exportFileWriter.append(endPoint.lineProtocol());
exportFileWriter.newLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public interface Tags {
* Request name tag.
*/
String REQUEST_NAME = "requestName";

/**
* Influx DB tag for a unique identifier for each execution(aka 'run') of a load test.
*/
String RUN_ID = "runId";

/**
* Test name field
*/
String TEST_NAME = "testName";
}

/**
Expand All @@ -48,11 +58,6 @@ public interface Fields {
*/
String THREAD_NAME = "threadName";

/**
* Test name field
*/
String TEST_NAME = "testName";

/**
* Node name field
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ public interface Tags {
* Node name field
*/
String NODE_NAME = "nodeName";

/**
* tag use for a unique id for this particular execution (aka 'run') of a load test.
*/
String RUN_ID = "runId";

/**
* Test name field.
*/
String TEST_NAME = "testName";
}

/**
Expand All @@ -41,7 +51,7 @@ public interface Fields {
/**
* Test name field.
*/
String TEST_NAME = "testName";
String PLACEHOLDER = "placeholder";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public interface Tags {
* Node name field
*/
String NODE_NAME = "nodeName";

String TEST_NAME = "testName";

String RUN_ID = "runId";


}

/**
Expand Down

0 comments on commit 2370d58

Please sign in to comment.