Search in sources :

Example 6 with MessageData

use of com.microsoft.applicationinsights.smoketest.schemav2.MessageData in project ApplicationInsights-Java by microsoft.

the class TraceJavaUtilLoggingTest method testTraceJavaUtilLogging.

@Test
@TargetUri("/traceJavaUtilLogging")
public void testTraceJavaUtilLogging() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(2);
    Envelope rdEnvelope = rdList.get(0);
    Envelope mdEnvelope1 = mdList.get(0);
    Envelope mdEnvelope2 = mdList.get(1);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    List<MessageData> logs = mockedIngestion.getMessageDataInRequest();
    logs.sort(Comparator.comparing(MessageData::getSeverityLevel));
    MessageData md1 = logs.get(0);
    MessageData md2 = logs.get(1);
    assertEquals("This is jul warning.", md1.getMessage());
    assertEquals(SeverityLevel.Warning, md1.getSeverityLevel());
    assertEquals("Logger", md1.getProperties().get("SourceType"));
    assertEquals("WARNING", md1.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
    assertNotNull(md1.getProperties().get("ThreadName"));
    assertEquals(4, md1.getProperties().size());
    assertEquals("This is jul severe.", md2.getMessage());
    assertEquals(SeverityLevel.Error, md2.getSeverityLevel());
    assertEquals("Logger", md2.getProperties().get("SourceType"));
    assertEquals("SEVERE", md2.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
    assertNotNull(md2.getProperties().get("ThreadName"));
    assertEquals(4, md2.getProperties().size());
    assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceJavaUtilLoggingUsingAgent/traceJavaUtilLogging");
    assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceJavaUtilLoggingUsingAgent/traceJavaUtilLogging");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 7 with MessageData

use of com.microsoft.applicationinsights.smoketest.schemav2.MessageData in project ApplicationInsights-Java by microsoft.

the class GrpcTest method doSimpleTest.

@Test
@TargetUri("/simple")
public void doSimpleTest() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 2);
    Envelope rdEnvelope1 = getRequestEnvelope(rdList, "GET /simple");
    Envelope rdEnvelope2 = getRequestEnvelope(rdList, "example.Greeter/SayHello");
    String operationId = rdEnvelope1.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
    // auto-collected grpc events are suppressed by exporter because they are noisy
    assertEquals(0, mockedIngestion.getCountForType("MessageData", operationId));
    Envelope rddEnvelope = getDependencyEnvelope(rddList, "example.Greeter/SayHello");
    RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    // TODO this is not correct (or at least not ideal)
    // see https://msazure.visualstudio.com/One/_workitems/edit/8687985
    assertEquals("grpc", rdd.getTarget());
    assertTrue(rd1.getProperties().isEmpty());
    assertTrue(rd1.getSuccess());
    assertTrue(rdd.getProperties().isEmpty());
    assertTrue(rdd.getSuccess());
    // TODO (trask): verify rd2
    assertParentChild(rd1, rdEnvelope1, rddEnvelope, "GET /simple");
    assertParentChild(rdd.getId(), rddEnvelope, rdEnvelope2, "GET /simple", "example.Greeter/SayHello", false);
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 8 with MessageData

use of com.microsoft.applicationinsights.smoketest.schemav2.MessageData in project ApplicationInsights-Java by microsoft.

the class TraceLog4j2Test method testTraceLog4j2.

@Test
@TargetUri("/traceLog4j2")
public void testTraceLog4j2() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(3);
    Envelope rdEnvelope = rdList.get(0);
    Envelope mdEnvelope1 = mdList.get(0);
    Envelope mdEnvelope2 = mdList.get(1);
    Envelope mdEnvelope3 = mdList.get(2);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    List<MessageData> logs = mockedIngestion.getMessageDataInRequest();
    logs.sort(Comparator.comparing(MessageData::getSeverityLevel));
    MessageData md1 = logs.get(0);
    MessageData md2 = logs.get(1);
    MessageData md3 = logs.get(2);
    assertEquals("This is log4j2 warn.", md1.getMessage());
    assertEquals(SeverityLevel.Warning, md1.getSeverityLevel());
    assertEquals("Logger", md1.getProperties().get("SourceType"));
    assertEquals("WARN", md1.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
    assertNotNull(md1.getProperties().get("ThreadName"));
    assertEquals("MDC value", md1.getProperties().get("MDC key"));
    assertEquals(5, md1.getProperties().size());
    assertEquals("This is log4j2 error.", md2.getMessage());
    assertEquals(SeverityLevel.Error, md2.getSeverityLevel());
    assertEquals("Logger", md2.getProperties().get("SourceType"));
    assertEquals("ERROR", md2.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
    assertNotNull(md1.getProperties().get("ThreadName"));
    assertEquals(4, md2.getProperties().size());
    assertEquals("This is log4j2 fatal.", md3.getMessage());
    assertEquals(SeverityLevel.Critical, md3.getSeverityLevel());
    assertEquals("Logger", md3.getProperties().get("SourceType"));
    assertEquals("FATAL", md3.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md3.getProperties().get("LoggerName"));
    assertNotNull(md3.getProperties().get("ThreadName"));
    assertEquals(4, md3.getProperties().size());
    assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceLog4j2UsingAgent/traceLog4j2");
    assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceLog4j2UsingAgent/traceLog4j2");
    assertParentChild(rd, rdEnvelope, mdEnvelope3, "GET /TraceLog4j2UsingAgent/traceLog4j2");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 9 with MessageData

use of com.microsoft.applicationinsights.smoketest.schemav2.MessageData in project ApplicationInsights-Java by microsoft.

the class TraceLog4j12Test method testTraceLog4j12.

@Test
@TargetUri("/traceLog4j12")
public void testTraceLog4j12() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(3);
    Envelope rdEnvelope = rdList.get(0);
    Envelope mdEnvelope1 = mdList.get(0);
    Envelope mdEnvelope2 = mdList.get(1);
    Envelope mdEnvelope3 = mdList.get(2);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    List<MessageData> logs = mockedIngestion.getMessageDataInRequest();
    logs.sort(Comparator.comparing(MessageData::getSeverityLevel));
    MessageData md1 = logs.get(0);
    MessageData md2 = logs.get(1);
    MessageData md3 = logs.get(2);
    assertEquals("This is log4j1.2 warn.", md1.getMessage());
    assertEquals(SeverityLevel.Warning, md1.getSeverityLevel());
    assertEquals("Logger", md1.getProperties().get("SourceType"));
    assertEquals("WARN", md1.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
    assertNotNull(md1.getProperties().get("ThreadName"));
    assertEquals("MDC value", md1.getProperties().get("MDC key"));
    assertEquals(5, md1.getProperties().size());
    assertEquals("This is log4j1.2 error.", md2.getMessage());
    assertEquals(SeverityLevel.Error, md2.getSeverityLevel());
    assertEquals("Logger", md2.getProperties().get("SourceType"));
    assertEquals("ERROR", md2.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md2.getProperties().get("LoggerName"));
    assertNotNull(md2.getProperties().get("ThreadName"));
    assertEquals(4, md2.getProperties().size());
    assertEquals("This is log4j1.2 fatal.", md3.getMessage());
    assertEquals(SeverityLevel.Critical, md3.getSeverityLevel());
    assertEquals("Logger", md3.getProperties().get("SourceType"));
    assertEquals("FATAL", md3.getProperties().get("LoggingLevel"));
    assertEquals("smoketestapp", md3.getProperties().get("LoggerName"));
    assertNotNull(md3.getProperties().get("ThreadName"));
    assertEquals(4, md3.getProperties().size());
    assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
    assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
    assertParentChild(rd, rdEnvelope, mdEnvelope3, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) MessageData(com.microsoft.applicationinsights.smoketest.schemav2.MessageData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Example 10 with MessageData

use of com.microsoft.applicationinsights.smoketest.schemav2.MessageData in project ApplicationInsights-Java by microsoft.

the class GrpcTest method doConversationTest.

@Test
@TargetUri("/conversation")
public void doConversationTest() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 2);
    Envelope rdEnvelope1 = getRequestEnvelope(rdList, "GET /conversation");
    Envelope rdEnvelope2 = getRequestEnvelope(rdList, "example.Greeter/Conversation");
    String operationId = rdEnvelope1.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", 1, operationId);
    // auto-collected grpc events are suppressed by exporter because they are noisy
    assertEquals(0, mockedIngestion.getCountForType("MessageData", operationId));
    Envelope rddEnvelope = getDependencyEnvelope(rddList, "example.Greeter/Conversation");
    RequestData rd1 = (RequestData) ((Data<?>) rdEnvelope1.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertEquals("grpc", rdd.getTarget());
    assertTrue(rd1.getProperties().isEmpty());
    assertTrue(rd1.getSuccess());
    assertTrue(rdd.getProperties().isEmpty());
    assertTrue(rdd.getSuccess());
    // TODO (trask): verify rd2
    assertParentChild(rd1, rdEnvelope1, rddEnvelope, "GET /conversation");
    assertParentChild(rdd.getId(), rddEnvelope, rdEnvelope2, "GET /conversation", "example.Greeter/Conversation", false);
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)9 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)9 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)8 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)2 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)1 ArrayList (java.util.ArrayList)1