Skip to content

Commit

Permalink
Add support for Live Metrics Stream (#2)
Browse files Browse the repository at this point in the history
* Ability to send live metrics

Signed-off-by: Adrián Moreno <[email protected]>

* Add documentation about the live metrics setting

Signed-off-by: Adrián Moreno <[email protected]>

* Fix documentation

Signed-off-by: Adrián Moreno <[email protected]>
  • Loading branch information
adrianmo authored Feb 20, 2020
1 parent 217f3f3 commit 3fd7ea4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ Then, restart JMeter and the plugin should be loaded.

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 test name and the Application Insights instrumentation key as a parameter as shown in image below.
Then, in the Parameters table, configure the following attributes.

| Attribute | Description | Required |
|---|---|---|
| *instrumentationKey* | The Instrumentation Key of your Application Insights instance | Yes |
| *testName* | Name of the test. This value is used to differentiate metrics across test runs or plans in Application Insights and allow you to filter them. | Yes |
| *liveMetrics* | Boolean to indicate whether or not real-time metrics are enabled and available in the [Live Metrics Stream](https://docs.microsoft.com/en-us/azure/azure-monitor/app/live-stream). Defaults to `true`. | No |

*Example of configuration:*

![Screenshot of configuration](docs/configuration.png "Screenshot of JMeter configuration")

Expand All @@ -55,6 +63,10 @@ In the image you can see an example of how you can visualize the duration of the

![Request duration](docs/requestduration.png "Screenshot of test requests duration")

Additionally, if you enabled `liveMetrics` in the configuration, you can watch your test performance in real-time in the Live Metrics Stream blade.

![Live Metrics Stream](docs/livemetrics.png "Screenshot of live metrics stream")

## Contributing

Feel free to contribute by forking and making pull requests, or simply by suggesting ideas through the
Expand Down
Binary file modified docs/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/livemetrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.adrianmo</groupId>
<artifactId>jmeter.backendlistener.azure</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>A JMeter plug-in that enables you to send test results to Azure Monitor.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.TelemetryConfiguration;
import com.microsoft.applicationinsights.internal.quickpulse.QuickPulse;
import com.microsoft.applicationinsights.internal.util.MapUtil;
import com.microsoft.applicationinsights.telemetry.Duration;
import com.microsoft.applicationinsights.telemetry.RequestTelemetry;
Expand All @@ -21,6 +22,7 @@ public class AzureBackendClient extends AbstractBackendListenerClient {
private TelemetryClient client;
private static final String TEST_NAME = "testName";
private static final String INSTRUMENTATION_KEY = "instrumentationKey";
private static final String LIVE_METRICS = "liveMetrics";

public AzureBackendClient() {
super();
Expand All @@ -31,13 +33,20 @@ public Arguments getDefaultParameters() {
Arguments arguments = new Arguments();
arguments.addArgument(TEST_NAME, "jmeter");
arguments.addArgument(INSTRUMENTATION_KEY, "");
arguments.addArgument(LIVE_METRICS, "true");

return arguments;
}

@Override
public void setupTest(BackendListenerContext context) throws Exception {
client = new TelemetryClient(TelemetryConfiguration.createDefault());
client.getContext().setInstrumentationKey(context.getParameter(INSTRUMENTATION_KEY));
boolean liveMetrics = context.getBooleanParameter(LIVE_METRICS, true);
TelemetryConfiguration config = TelemetryConfiguration.createDefault();
config.setInstrumentationKey(context.getParameter(INSTRUMENTATION_KEY));
client = new TelemetryClient(config);
if (liveMetrics) {
QuickPulse.INSTANCE.initialize(config);
}
super.setupTest(context);
}

Expand Down

0 comments on commit 3fd7ea4

Please sign in to comment.