diff --git a/README.md b/README.md
index 77e9b87..c15d01d 100644
--- a/README.md
+++ b/README.md
@@ -8,32 +8,67 @@ A JMeter plug-in that enables you to send test results to Azure Application Insi
### Description
-JMeter Backend Azure is a JMeter plugin enabling you to send test results to an Azure Application Insights. This plugin is inspired in the [Elasticsearch](https://github.com/delirius325/jmeter-elasticsearch-backend-listener) and [Kafka](https://github.com/rahulsinghai/jmeter-backend-listener-kafka) backend listener plugins.
-
-### Build
-
-- To build the artifact, execute below Maven command. Make sure `JAVA_HOME` is set properly.
+JMeter Backend Azure is a JMeter plugin enabling you to send test results to an Azure Application Insights.
+
+The following test results metrics are exposed by the plugin.
+
+- TestStartTime
+- SampleStartTime
+- SampleEndTime
+- ResponseCode
+- Duration
+- URL
+- SampleLabel
+- SampleCount
+- ErrorCount
+- Bytes
+- SentBytes
+- ConnectTime
+- IdleTime
+- ThreadName
+- GrpThreads
+- AllThreads
+
+### Plugin installation
+
+Once you have built or downloaded the plugin JAR file from the [releases](https://github.com/adrianmo/jmeter-backend-azure/releases) section,
+move the JAR to your `$JMETER_HOME/lib/ext`.
```bash
-mvn clean package
+mv target/jmeter.backendlistener.azure-VERSION.jar $JMETER_HOME/lib/ext/
```
-- Move the resulting JAR to your `JMETER_HOME/lib/ext`.
+Then, restart JMeter and the plugin should be loaded.
-```bash
-mv target/jmeter.backendlistener.azure-VERSION.jar $JMETER_HOME/lib/ext/
-```
+### JMeter configuration
+
+To make JMeter send test result metrics to Azure Application Insights, in your **Test Pan**, right click on
+**Thread Group** > Add > Listener > Backend Listener, and choose `io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient` as `Backend Listener Implementation`.
+Then, specify the metric name and the Application Insights instrumentation key as a parameter as shown in image below.
-- Restart JMeter
+![Screenshot of configuration](docs/configuration.png "Screenshot of JMeter configuration")
-### Configuring jmeter-backend-azure plug-in
+### Visualization
-- In your **Test Pan**, right click on **Thread Group** > Add > Listener > Backend Listener
-- Choose `io.github.adrianmo.jmeter.backendlistener.azure.AzureBackendClient` as `Backend Listener Implementation`.
-- Specify the Application Insights instrumentation key as a parameter as shown in image below:
+Test result metrics are available in the **requests** dimension of your Application Insights instance.
+In the image you can see an example of how you can visualize the duration of the requests made during your test run.
-![Screenshot of configuration](docs/configuration.png "Screenshot of configuration")
+![Request duration](docs/requestduration.png "Screenshot of test requests duration")
## Contributing
-Feel free to contribute by branching and making pull requests, or simply by suggesting ideas through the "Issues" tab.
+Feel free to contribute by forking and making pull requests, or simply by suggesting ideas through the
+[Issues](https://github.com/adrianmo/jmeter-backend-azure/issues) section.
+
+### Build
+
+You can make changes to the plugin and build your own JAR file to test changes. To build the artifact,
+execute below Maven command. Make sure `JAVA_HOME` is set properly.
+
+```bash
+mvn clean package
+```
+
+---
+
+This plugin is inspired in the [Elasticsearch](https://github.com/delirius325/jmeter-elasticsearch-backend-listener) and [Kafka](https://github.com/rahulsinghai/jmeter-backend-listener-kafka) backend listener plugins.
\ No newline at end of file
diff --git a/docs/configuration.png b/docs/configuration.png
index 405f7a3..f41be6a 100644
Binary files a/docs/configuration.png and b/docs/configuration.png differ
diff --git a/docs/requestduration.png b/docs/requestduration.png
new file mode 100644
index 0000000..702e308
Binary files /dev/null and b/docs/requestduration.png differ
diff --git a/pom.xml b/pom.xml
index 379e32d..3c4fc64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
io.github.adrianmo
jmeter.backendlistener.azure
- 0.1.0
+ 0.1.1
jar
${project.artifactId}
A JMeter plug-in that enables you to send test results to Azure Monitor.
diff --git a/src/main/java/io/github/adrianmo/jmeter/backendlistener/azure/AzureBackendClient.java b/src/main/java/io/github/adrianmo/jmeter/backendlistener/azure/AzureBackendClient.java
index 3005369..25f15e3 100644
--- a/src/main/java/io/github/adrianmo/jmeter/backendlistener/azure/AzureBackendClient.java
+++ b/src/main/java/io/github/adrianmo/jmeter/backendlistener/azure/AzureBackendClient.java
@@ -3,7 +3,8 @@
import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.TelemetryConfiguration;
import com.microsoft.applicationinsights.internal.util.MapUtil;
-import com.microsoft.applicationinsights.telemetry.MetricTelemetry;
+import com.microsoft.applicationinsights.telemetry.Duration;
+import com.microsoft.applicationinsights.telemetry.RequestTelemetry;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContextService;
@@ -18,6 +19,7 @@
public class AzureBackendClient extends AbstractBackendListenerClient {
private TelemetryClient client;
+ private static final String METRIC_NAME = "metricName";
private static final String INSTRUMENTATION_KEY = "instrumentationKey";
public AzureBackendClient() {
@@ -27,6 +29,7 @@ public AzureBackendClient() {
@Override
public Arguments getDefaultParameters() {
Arguments arguments = new Arguments();
+ arguments.addArgument(METRIC_NAME, "jmeter");
arguments.addArgument(INSTRUMENTATION_KEY, "");
return arguments;
}
@@ -38,8 +41,14 @@ public void setupTest(BackendListenerContext context) throws Exception {
super.setupTest(context);
}
- private void trackMetric(String name, Double value, SampleResult sr) {
+ private void trackRequest(String name, SampleResult sr) {
Map properties = new HashMap();
+ properties.put("Bytes", Long.toString(sr.getBytesAsLong()));
+ properties.put("SentBytes", Long.toString(sr.getSentBytes()));
+ properties.put("ConnectTime", Long.toString(sr.getConnectTime()));
+ properties.put("ErrorCount", Integer.toString(sr.getErrorCount()));
+ properties.put("IdleTime", Double.toString(sr.getIdleTime()));
+ properties.put("Latency", Double.toString(sr.getLatency()));
properties.put("BodySize", Long.toString(sr.getBodySizeAsLong()));
properties.put("TestStartTime", Long.toString(JMeterContextService.getTestStartTime()));
properties.put("SampleStartTime", Long.toString(sr.getStartTime()));
@@ -50,24 +59,20 @@ private void trackMetric(String name, Double value, SampleResult sr) {
properties.put("ResponseCode", sr.getResponseCode());
properties.put("GrpThreads", Integer.toString(sr.getGroupThreads()));
properties.put("AllThreads", Integer.toString(sr.getAllThreads()));
+ properties.put("SampleCount", Integer.toString(sr.getSampleCount()));
- MetricTelemetry metric = new MetricTelemetry(name, value);
- metric.setCount(sr.getSampleCount());
- metric.setTimestamp(new Date(sr.getTimeStamp()));
- MapUtil.copy(properties, metric.getProperties());
- client.trackMetric(metric);
+ Date timestamp = new Date(sr.getTimeStamp());
+ Duration duration = new Duration(sr.getTime());
+ RequestTelemetry req = new RequestTelemetry(name, timestamp, duration, sr.getResponseCode(), sr.getErrorCount() == 0);
+ req.setUrl(sr.getURL());
+ MapUtil.copy(properties, req.getProperties());
+ client.trackRequest(req);
}
@Override
public void handleSampleResults(List results, BackendListenerContext context) {
for (SampleResult sr : results) {
- trackMetric("Bytes", (double)sr.getBytesAsLong(), sr);
- trackMetric("SentBytes", (double)sr.getSentBytes(), sr);
- trackMetric("ConnectTime", (double)sr.getConnectTime(), sr);
- trackMetric("ErrorCount", (double)sr.getErrorCount(), sr);
- trackMetric("IdleTime", (double)sr.getIdleTime(), sr);
- trackMetric("Latency", (double)sr.getLatency(), sr);
- trackMetric("ResponseTime", (double)sr.getTime(), sr);
+ trackRequest(context.getParameter(METRIC_NAME), sr);
}
}