Search in sources :

Example 36 with RequestData

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

the class JmsDisabledTest 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();
    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"));
}
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 37 with RequestData

use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData 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"));
}
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 38 with RequestData

use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData 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);
}
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 39 with RequestData

use of com.microsoft.applicationinsights.smoketest.schemav2.RequestData 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)

Example 40 with RequestData

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

the class TraceLogBackTest method testTraceLogBack.

@Test
@TargetUri("/traceLogBack")
public void testTraceLogBack() 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 logback 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"));
    // TODO add MDC instrumentation for jboss logging
    if (!currentImageName.contains("wildfly")) {
        assertEquals("MDC value", md1.getProperties().get("MDC key"));
        assertEquals(5, md1.getProperties().size());
    } else {
        assertEquals(4, md1.getProperties().size());
    }
    assertEquals("This is logback 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());
    assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceLogBackUsingAgent/traceLogBack");
    assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceLogBackUsingAgent/traceLogBack");
}
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)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)48 Test (org.junit.Test)47 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)8 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)5 RequestDataMatchers.hasDuration (com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration)4 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)4 Duration (com.microsoft.applicationinsights.smoketest.telemetry.Duration)4 PageViewData (com.microsoft.applicationinsights.smoketest.schemav2.PageViewData)3 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)2 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)2 Description (org.hamcrest.Description)2 Matcher (org.hamcrest.Matcher)2 TypeSafeMatcher (org.hamcrest.TypeSafeMatcher)2 Stopwatch (com.google.common.base.Stopwatch)1