Skip to content

Commit

Permalink
Set metric timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Adrián Moreno <adrian@morenomartinez.com>
  • Loading branch information
adrianmo committed Feb 10, 2020
1 parent f924354 commit 22beb78
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ hs_err_pid*
.idea/
*.iml

target/
target/
dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.TelemetryConfiguration;
import com.microsoft.applicationinsights.internal.util.MapUtil;
import com.microsoft.applicationinsights.telemetry.MetricTelemetry;
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
import org.apache.jmeter.visualizers.backend.BackendListenerContext;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -48,10 +51,13 @@ private void trackMetric(String name, Double value, SampleResult sr) {
properties.put("GrpThreads", Integer.toString(sr.getGroupThreads()));
properties.put("AllThreads", Integer.toString(sr.getAllThreads()));

client.trackMetric(name, value, sr.getSampleCount(), value, value, value, properties);
MetricTelemetry metric = new MetricTelemetry(name, value);
metric.setCount(sr.getSampleCount());
metric.setTimestamp(new Date(sr.getTimeStamp()));
MapUtil.copy(properties, metric.getProperties());
client.trackMetric(metric);
}


@Override
public void handleSampleResults(List<SampleResult> results, BackendListenerContext context) {
for (SampleResult sr : results) {
Expand Down

0 comments on commit 22beb78

Please sign in to comment.