From f3c16e3528bd6daf2fda2834393ae856a2cf5c1c Mon Sep 17 00:00:00 2001 From: Erik Ostermueller Date: Tue, 2 Jan 2018 00:57:16 -0600 Subject: [PATCH 1/3] testName now used in all 3 tables --- gradlew | 0 .../JMeterInfluxDBBackendListenerClient.java | 25 +++++++++++++++---- .../JMeterInfluxDBImportFileClient.java | 4 +-- .../config/influxdb/RequestMeasurement.java | 15 +++++++---- .../influxdb/TestStartEndMeasurement.java | 12 ++++++++- .../influxdb/VirtualUsersMeasurement.java | 6 +++++ 6 files changed, 49 insertions(+), 13 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java index f2a8c3d..9007f6b 100644 --- a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java +++ b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java @@ -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"; @@ -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 */ @@ -126,10 +133,11 @@ public void handleSampleResults(List 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); @@ -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, ""); @@ -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"); @@ -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("1", "1") .build()); parseSamplers(context); @@ -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(); @@ -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()); } diff --git a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBImportFileClient.java b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBImportFileClient.java index b577617..597b2f6 100644 --- a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBImportFileClient.java +++ b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBImportFileClient.java @@ -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(); @@ -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(); diff --git a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/RequestMeasurement.java b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/RequestMeasurement.java index dfe308a..4e36571 100644 --- a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/RequestMeasurement.java +++ b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/RequestMeasurement.java @@ -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"; } /** @@ -48,11 +58,6 @@ public interface Fields { */ String THREAD_NAME = "threadName"; - /** - * Test name field - */ - String TEST_NAME = "testName"; - /** * Node name field */ diff --git a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/TestStartEndMeasurement.java b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/TestStartEndMeasurement.java index 5da621c..d1092f9 100644 --- a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/TestStartEndMeasurement.java +++ b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/TestStartEndMeasurement.java @@ -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"; } /** @@ -41,7 +51,7 @@ public interface Fields { /** * Test name field. */ - String TEST_NAME = "testName"; + String PLACEHOLDER = "placeholder"; } /** diff --git a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/VirtualUsersMeasurement.java b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/VirtualUsersMeasurement.java index 802f994..ea714b0 100644 --- a/src/main/java/rocks/nt/apm/jmeter/config/influxdb/VirtualUsersMeasurement.java +++ b/src/main/java/rocks/nt/apm/jmeter/config/influxdb/VirtualUsersMeasurement.java @@ -24,6 +24,12 @@ public interface Tags { * Node name field */ String NODE_NAME = "nodeName"; + + String TEST_NAME = "testName"; + + String RUN_ID = "runId"; + + } /** From 626639a1ed447c6abd66c7a9667c5ab227f2a48f Mon Sep 17 00:00:00 2001 From: Erik Ostermueller Date: Sun, 7 Jan 2018 00:38:27 -0600 Subject: [PATCH 2/3] using 1.2x for the version/jar --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 6de12d8..9a47cb6 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'java' apply plugin: 'eclipse' sourceCompatibility = 1.7 -version = '1.2' +version = '1.2x' def title = 'JMeterInfluxDBListener' jar { @@ -35,4 +35,4 @@ task fatJar(type: Jar) { task wrapper(type: Wrapper) { gradleVersion = '2.12' -} \ No newline at end of file +} From c73724d2c4ef6c6516d11c4fffc731a8f994fa81 Mon Sep 17 00:00:00 2001 From: Erik Ostermueller Date: Sun, 7 Jan 2018 00:39:11 -0600 Subject: [PATCH 3/3] using placeholder fieldname instead of 1 --- .../nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java index 9007f6b..9b9a850 100644 --- a/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java +++ b/src/main/java/rocks/nt/apm/jmeter/JMeterInfluxDBBackendListenerClient.java @@ -179,7 +179,7 @@ public void setupTest(BackendListenerContext context) throws Exception { .tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED) .tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName) .tag(TestStartEndMeasurement.Tags.TEST_NAME, testName) - .addField("1", "1") + .addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1") .build()); parseSamplers(context);