use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class MockedAppInsightsIngestionServer method getMessageDataInRequest.
public <T extends Domain> List<T> getMessageDataInRequest() {
List<Envelope> items = getItemsEnvelopeDataType("MessageData");
List<T> dataItems = new ArrayList<>();
for (Envelope e : items) {
String message = ((MessageData) ((Data<?>) e.getData()).getBaseData()).getMessage();
if (e.getTags().containsKey("ai.operation.id") && !ignoreMessageData(message)) {
Data<T> dt = (Data<T>) e.getData();
dataItems.add(dt.getBaseData());
}
}
return dataItems;
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class PerfCountersDataTest method testPerformanceCounterData.
@Test
@TargetUri(value = "index.jsp", delay = 5000)
public void testPerformanceCounterData() throws Exception {
System.out.println("Waiting for performance data...");
long start = System.currentTimeMillis();
// need to accommodate for START_COLLECTING_DELAY_IN_MILLIS = 60 seconds
int timeout = 70;
Envelope availableMem = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Memory\\Available Bytes"), timeout, TimeUnit.SECONDS);
Envelope totalCpu = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Processor(_Total)\\% Processor Time"), timeout, TimeUnit.SECONDS);
Envelope processIo = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\IO Data Bytes/sec"), timeout, TimeUnit.SECONDS);
Envelope processMemUsed = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\Private Bytes"), timeout, TimeUnit.SECONDS);
Envelope processCpu = mockedIngestion.waitForItem(getPerfMetricPredicate("\\Process(??APP_WIN32_PROC??)\\% Processor Time"), timeout, TimeUnit.SECONDS);
System.out.println("PerformanceCounterData are good: " + (System.currentTimeMillis() - start));
MetricData metricMem = getBaseData(availableMem);
assertPerfMetric(metricMem);
assertEquals("\\Memory\\Available Bytes", metricMem.getMetrics().get(0).getName());
MetricData pdCpu = getBaseData(totalCpu);
assertPerfMetric(pdCpu);
assertEquals("\\Processor(_Total)\\% Processor Time", pdCpu.getMetrics().get(0).getName());
assertPerfMetric(getBaseData(processIo));
assertPerfMetric(getBaseData(processMemUsed));
assertPerfMetric(getBaseData(processCpu));
start = System.currentTimeMillis();
System.out.println("Waiting for metric data...");
Envelope deadlocks = mockedIngestion.waitForItem(getPerfMetricPredicate("Suspected Deadlocked Threads"), timeout, TimeUnit.SECONDS);
Envelope heapUsed = mockedIngestion.waitForItem(getPerfMetricPredicate("Heap Memory Used (MB)"), timeout, TimeUnit.SECONDS);
Envelope gcTotalCount = mockedIngestion.waitForItem(getPerfMetricPredicate("GC Total Count"), timeout, TimeUnit.SECONDS);
Envelope gcTotalTime = mockedIngestion.waitForItem(getPerfMetricPredicate("GC Total Time"), timeout, TimeUnit.SECONDS);
System.out.println("MetricData are good: " + (System.currentTimeMillis() - start));
MetricData mdDeadlocks = getBaseData(deadlocks);
assertPerfMetric(mdDeadlocks);
assertEquals(0.0, mdDeadlocks.getMetrics().get(0).getValue(), Math.ulp(0.0));
MetricData mdHeapUsed = getBaseData(heapUsed);
assertPerfMetric(mdHeapUsed);
assertTrue(mdHeapUsed.getMetrics().get(0).getValue() > 0.0);
MetricData mdGcTotalCount = getBaseData(gcTotalCount);
assertPerfMetric(mdGcTotalCount);
MetricData mdGcTotalTime = getBaseData(gcTotalTime);
assertPerfMetric(mdGcTotalTime);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationSeven.
@Test
@TargetUri("/customInstrumentationSeven")
public void customInstrumentationSeven() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.seven");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationOne.
@Test
@TargetUri("/customInstrumentationOne")
public void customInstrumentationOne() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.one");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationNine.
@Test
@TargetUri("/customInstrumentationNine")
public void customInstrumentationNine() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 2);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
Envelope nineEnvelope = null;
Envelope httpEnvelope = null;
RemoteDependencyData nineRdd = null;
RemoteDependencyData httpRdd = null;
for (Envelope loopEnvelope : rddList) {
RemoteDependencyData loopData = (RemoteDependencyData) ((Data<?>) loopEnvelope.getData()).getBaseData();
if (loopData.getType().equals("OTHER")) {
nineEnvelope = loopEnvelope;
nineRdd = loopData;
} else if (loopData.getType().equals("Http (tracked component)")) {
httpEnvelope = loopEnvelope;
httpRdd = loopData;
} else {
throw new IllegalStateException("Unexpected remote dependency type: " + loopData.getType());
}
}
assertTrue(rd.getSuccess());
assertNotNull(nineRdd);
assertEquals(nineRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.nine");
assertEquals(nineRdd.getType(), "OTHER");
assertEquals(nineRdd.getSuccess(), true);
assertParentChild(rd, rdEnvelope, nineEnvelope, "GET /CustomInstrumentation/*");
assertNotNull(httpRdd);
assertParentChild(rd, rdEnvelope, httpEnvelope, "GET /CustomInstrumentation/*");
}
Aggregations