use of com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails in project ApplicationInsights-Java by microsoft.
the class CustomInstrumentationTest method customInstrumentationThree.
@Test
@TargetUri("/customInstrumentationThree")
public void customInstrumentationThree() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
List<Envelope> edList = mockedIngestion.waitForItemsInRequest("ExceptionData", 1);
Envelope rdEnvelope = rdList.get(0);
Envelope rddEnvelope = rddList.get(0);
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
assertTrue(rd.getSuccess());
assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.three");
assertEquals(rdd.getType(), "OTHER");
assertEquals(rdd.getSuccess(), false);
List<ExceptionDetails> exceptions = ed.getExceptions();
assertEquals(exceptions.size(), 1);
assertEquals(exceptions.get(0).getMessage(), "Three");
assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
assertParentChild(rd, rdEnvelope, edEnvelope, "GET /CustomInstrumentation/*");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testAutoExceptionWithFailedRequest.
@Test
@TargetUri("/autoExceptionWithFailedRequest")
public void testAutoExceptionWithFailedRequest() 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.waitForItems(new Predicate<Envelope>() {
@Override
public boolean test(Envelope input) {
if (!"ExceptionData".equals(input.getData().getBaseType())) {
return false;
}
if (!operationId.equals(input.getTags().get("ai.operation.id"))) {
return false;
}
// lastly, filter out ExceptionData captured from tomcat logger
ExceptionData data = (ExceptionData) ((Data<?>) input.getData()).getBaseData();
return !data.getProperties().containsKey("LoggerName");
}
}, 1, 10, TimeUnit.SECONDS);
Envelope edEnvelope = edList.get(0);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
ExceptionData ed = (ExceptionData) ((Data<?>) edEnvelope.getData()).getBaseData();
assertFalse(rd.getSuccess());
ExceptionDetails details = getExceptionDetails(ed);
assertEquals("This is a auto thrown exception !", details.getMessage());
}
use of com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails 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");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails in project ApplicationInsights-Java by microsoft.
the class TraceLog4j2Test method testTraceLog4j2WithException.
@Test
@TargetUri("/traceLog4j2WithException")
public void testTraceLog4j2WithException() 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 /TraceLog4j2UsingAgent/traceLog4j2WithException");
}
Aggregations