use of com.microsoft.applicationinsights.smoketest.schemav2.EventData in project ApplicationInsights-Java by microsoft.
the class KafkaDisabledTest method doMostBasicTest.
@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
String operationId = rdEnvelope.getTags().get("ai.operation.id");
assertEquals(0, mockedIngestion.getCountForType("EventData"));
assertEquals("GET /sendMessage", rd.getName());
assertEquals("200", rd.getResponseCode());
assertTrue(rd.getProperties().isEmpty());
assertTrue(rd.getSuccess());
// verify the downstream http dependency that is no longer part of the same trace
List<Envelope> rddList = mockedIngestion.waitForItems("RemoteDependencyData", 1);
Envelope rddEnvelope = rddList.get(0);
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertEquals("GET /", rdd.getName());
assertEquals("https://www.bing.com", rdd.getData());
assertTrue(rdd.getProperties().isEmpty());
assertTrue(rdd.getSuccess());
// sleep a bit and make sure no kafka "requests" or dependencies are reported
Thread.sleep(5000);
assertEquals(1, mockedIngestion.getCountForType("RequestData"));
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
}
use of com.microsoft.applicationinsights.smoketest.schemav2.EventData in project ApplicationInsights-Java by microsoft.
the class KafkaTest method doMostBasicTest.
@Test
@TargetUri("/sendMessage")
public void doMostBasicTest() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 2);
Envelope rdEnvelope1 = getRequestEnvelope(rdList, "GET /sendMessage");
String operationId = rdEnvelope1.getTags().get("ai.operation.id");
List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 2, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope rdEnvelope2 = getRequestEnvelope(rdList, "mytopic process");
Envelope rddEnvelope1 = getDependencyEnvelope(rddList, "mytopic send");
Envelope rddEnvelope2 = getDependencyEnvelope(rddList, "GET /");
RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
RequestData rd2 = (RequestData) ((Data<?>) rdEnvelope2.getData()).getBaseData();
RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
assertEquals("GET /sendMessage", rd1.getName());
assertTrue(rd1.getProperties().isEmpty());
assertTrue(rd1.getSuccess());
assertEquals("mytopic send", rdd1.getName());
assertNull(rdd1.getData());
assertEquals("Queue Message | kafka", rdd1.getType());
assertEquals("mytopic", rdd1.getTarget());
assertTrue(rdd1.getProperties().isEmpty());
assertTrue(rdd1.getSuccess());
assertEquals("mytopic process", rd2.getName());
assertEquals("mytopic", rd2.getSource());
assertTrue(rd2.getProperties().isEmpty());
assertTrue(rd2.getSuccess());
assertEquals("GET /", rdd2.getName());
assertEquals("https://www.bing.com", rdd2.getData());
assertEquals("Http", rdd2.getType());
assertEquals("www.bing.com", rdd2.getTarget());
assertTrue(rdd2.getProperties().isEmpty());
assertTrue(rdd2.getSuccess());
assertParentChild(rd1, rdEnvelope1, rddEnvelope1, "GET /sendMessage");
assertParentChild(rdd1.getId(), rddEnvelope1, rdEnvelope2, "GET /sendMessage", "mytopic process", false);
assertParentChild(rd2.getId(), rdEnvelope2, rddEnvelope2, "mytopic process", "mytopic process", false);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.EventData in project ApplicationInsights-Java by microsoft.
the class TelemetryFilteringSmokeTest method testRegularJdbc.
@Test
@TargetUri("/regular-jdbc")
public void testRegularJdbc() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope rddEnvelope = rddList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
assertEquals("87654321-0000-0000-0000-0FEEDDADBEEF", rdEnvelope.getIKey());
assertTrue(rd.getSuccess());
assertEquals("SQL", rdd.getType());
assertEquals("testdb", rdd.getTarget());
assertEquals("SELECT testdb.abc", rdd.getName());
assertEquals("select * from abc", rdd.getData());
assertEquals("87654321-0000-0000-0000-0FEEDDADBEEF", rddEnvelope.getIKey());
assertTrue(rdd.getSuccess());
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /TelemetryFiltering/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.EventData in project ApplicationInsights-Java by microsoft.
the class TraceJavaUtilLoggingTest method testTraceJavaUtilLoggingWithExeption.
@Test
@TargetUri("traceJavaUtilLoggingWithException")
public void testTraceJavaUtilLoggingWithExeption() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> edList = mockedIngestion.waitForItemsInOperation("ExceptionData", 1, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
assertEquals("Fake Exception", ed.getExceptions().get(0).getMessage());
assertEquals(SeverityLevel.Error, ed.getSeverityLevel());
assertEquals("This is an exception!", ed.getProperties().get("Logger Message"));
assertEquals("Logger", ed.getProperties().get("SourceType"));
assertEquals("SEVERE", ed.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", ed.getProperties().get("LoggerName"));
assertNotNull(ed.getProperties().get("ThreadName"));
assertEquals(5, ed.getProperties().size());
assertParentChild(rd, rdEnvelope, edEnvelope, "GET /TraceJavaUtilLoggingUsingAgent/traceJavaUtilLoggingWithException");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.EventData in project ApplicationInsights-Java by microsoft.
the class TraceLog4j12Test method testTraceLog4j1_2WithExeption.
@Test
@TargetUri("traceLog4j1_2WithException")
public void testTraceLog4j1_2WithExeption() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
Envelope rdEnvelope = rdList.get(0);
String operationId = rdEnvelope.getTags().get("ai.operation.id");
List<Envelope> edList = mockedIngestion.waitForItemsInOperation("ExceptionData", 1, operationId);
assertEquals(0, mockedIngestion.getCountForType("EventData"));
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
List<ExceptionDetails> details = ed.getExceptions();
ExceptionDetails ex = details.get(0);
assertEquals("Fake Exception", ex.getMessage());
assertEquals(SeverityLevel.Error, ed.getSeverityLevel());
assertEquals("This is an exception!", ed.getProperties().get("Logger Message"));
assertEquals("Logger", ed.getProperties().get("SourceType"));
assertEquals("ERROR", ed.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", ed.getProperties().get("LoggerName"));
assertNotNull(ed.getProperties().get("ThreadName"));
assertEquals("MDC value", ed.getProperties().get("MDC key"));
assertEquals(6, ed.getProperties().size());
assertParentChild(rd, rdEnvelope, edEnvelope, "GET /TraceLog4j1_2UsingAgent/traceLog4j1_2WithException");
}
Aggregations