use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method validateSlowTest.
private void validateSlowTest(int expectedDurationSeconds, String operationName) throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
long actual = rd.getDuration().getTotalMilliseconds();
long expected = (new Duration(0, 0, 0, expectedDurationSeconds, 0).getTotalMilliseconds());
// 2 seconds
long tolerance = 2 * 1000;
long min = expected - tolerance;
long max = expected + tolerance;
System.out.printf("Slow response time: expected=%d, actual=%d%n", expected, actual);
assertThat(actual, both(greaterThanOrEqualTo(min)).and(lessThan(max)));
assertEquals(operationName, rdEnvelope.getTags().get("ai.operation.name"));
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data in project ApplicationInsights-Java by microsoft.
the class MockedAppInsightsIngestionServer method getTelemetryDataByType.
private <T extends Domain> List<T> getTelemetryDataByType(String type, boolean inRequestOnly) {
Objects.requireNonNull(type, "type");
List<Envelope> items = getItemsEnvelopeDataType(type);
List<T> dataItems = new ArrayList<>();
for (Envelope e : items) {
if (!inRequestOnly || e.getTags().containsKey("ai.operation.id")) {
Data<T> dt = (Data<T>) e.getData();
dataItems.add(dt.getBaseData());
}
}
return dataItems;
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Data 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.Data 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.Data 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/*");
}
Aggregations