Search in sources :

Example 31 with Data

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

the class CustomInstrumentationTest method customInstrumentationOne.

@Test
@TargetUri("/customInstrumentationOne")
public void customInstrumentationOne() 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.one");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 32 with Data

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

the class CustomInstrumentationTest method customInstrumentationNine.

@Test
@TargetUri("/customInstrumentationNine")
public void customInstrumentationNine() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 2);
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    Envelope nineEnvelope = null;
    Envelope httpEnvelope = null;
    RemoteDependencyData nineRdd = null;
    RemoteDependencyData httpRdd = null;
    for (Envelope loopEnvelope : rddList) {
        RemoteDependencyData loopData = (RemoteDependencyData) ((Data<?>) loopEnvelope.getData()).getBaseData();
        if (loopData.getType().equals("OTHER")) {
            nineEnvelope = loopEnvelope;
            nineRdd = loopData;
        } else if (loopData.getType().equals("Http (tracked component)")) {
            httpEnvelope = loopEnvelope;
            httpRdd = loopData;
        } else {
            throw new IllegalStateException("Unexpected remote dependency type: " + loopData.getType());
        }
    }
    assertTrue(rd.getSuccess());
    assertNotNull(nineRdd);
    assertEquals(nineRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.nine");
    assertEquals(nineRdd.getType(), "OTHER");
    assertEquals(nineRdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, nineEnvelope, "GET /CustomInstrumentation/*");
    assertNotNull(httpRdd);
    assertParentChild(rd, rdEnvelope, httpEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 33 with Data

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

the class CustomInstrumentationTest method customInstrumentationFive.

@Test
@TargetUri("/customInstrumentationFive")
public void customInstrumentationFive() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 4);
    Envelope rdEnvelope = rdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    Envelope fiveEnvelope = null;
    Envelope sixEnvelope = null;
    Envelope oneEnvelope = null;
    Envelope twoEnvelope = null;
    RemoteDependencyData fiveRdd = null;
    RemoteDependencyData sixRdd = null;
    RemoteDependencyData oneRdd = null;
    RemoteDependencyData twoRdd = null;
    for (Envelope loopEnvelope : rddList) {
        RemoteDependencyData loopData = (RemoteDependencyData) ((Data<?>) loopEnvelope.getData()).getBaseData();
        if (loopData.getName().endsWith(".five")) {
            fiveEnvelope = loopEnvelope;
            fiveRdd = loopData;
        } else if (loopData.getName().endsWith(".six")) {
            sixEnvelope = loopEnvelope;
            sixRdd = loopData;
        } else if (loopData.getName().endsWith(".one")) {
            oneEnvelope = loopEnvelope;
            oneRdd = loopData;
        } else if (loopData.getName().endsWith(".two")) {
            twoEnvelope = loopEnvelope;
            twoRdd = loopData;
        } else {
            throw new IllegalStateException("Unexpected remote dependency: " + loopData.getName());
        }
    }
    assertTrue(rd.getSuccess());
    assertNotNull(fiveRdd);
    assertEquals(fiveRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.five");
    assertEquals(fiveRdd.getType(), "OTHER");
    assertEquals(fiveRdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, fiveEnvelope, "GET /CustomInstrumentation/*");
    assertNotNull(sixRdd);
    assertEquals(sixRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.six");
    assertEquals(sixRdd.getType(), "OTHER");
    assertEquals(sixRdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, sixEnvelope, "GET /CustomInstrumentation/*");
    assertNotNull(oneRdd);
    assertEquals(oneRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.one");
    assertEquals(oneRdd.getType(), "OTHER");
    assertEquals(oneRdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, oneEnvelope, "GET /CustomInstrumentation/*");
    assertNotNull(twoRdd);
    assertEquals(twoRdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.two");
    assertEquals(twoRdd.getType(), "OTHER");
    assertEquals(twoRdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, twoEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 34 with Data

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

the class SpringBootControllerSpansEnabledTest method trackEvent.

@Test
@TargetUri("/basic/trackEvent")
public void trackEvent() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    Envelope rdEnvelope = rdList.get(0);
    String operationId = rdEnvelope.getTags().get("ai.operation.id");
    mockedIngestion.waitForItemsInOperation("EventData", 2, operationId);
    // TODO get event data envelope and verify value
    List<EventData> data = mockedIngestion.getTelemetryDataByTypeInRequest("EventData");
    assertThat(data, hasItem(new TypeSafeMatcher<EventData>() {

        final String name = "EventDataTest";

        final Matcher<String> nameMatcher = Matchers.equalTo(name);

        @Override
        protected boolean matchesSafely(EventData item) {
            return nameMatcher.matches(item.getName());
        }

        @Override
        public void describeTo(Description description) {
            description.appendDescriptionOf(nameMatcher);
        }
    }));
    assertThat(data, hasItem(new TypeSafeMatcher<EventData>() {

        final String expectedKey = "key";

        final String expectedName = "EventDataPropertyTest";

        final String expectedPropertyValue = "value";

        final Double expectedMetricValue = 1d;

        final Matcher<Map<? extends String, ? extends Double>> metricMatcher = Matchers.hasEntry(expectedKey, expectedMetricValue);

        final Matcher<Map<? extends String, ? extends String>> propertyMatcher = Matchers.hasEntry(expectedKey, expectedPropertyValue);

        final Matcher<String> nameMatcher = Matchers.equalTo(expectedName);

        @Override
        public void describeTo(Description description) {
            description.appendDescriptionOf(nameMatcher);
            description.appendDescriptionOf(propertyMatcher);
            description.appendDescriptionOf(metricMatcher);
        }

        @Override
        protected boolean matchesSafely(EventData item) {
            return nameMatcher.matches(item.getName()) && propertyMatcher.matches(item.getProperties()) && metricMatcher.matches(item.getMeasurements());
        }
    }));
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Matcher(org.hamcrest.Matcher) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) EventData(com.microsoft.applicationinsights.smoketest.schemav2.EventData) Test(org.junit.Test)

Example 35 with Data

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

the class SpringBootControllerSpansEnabledTest method testAsyncDependencyCall.

@Test
@TargetUri("/asyncDependencyCall")
public void testAsyncDependencyCall() 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", 3, operationId);
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    Envelope rddEnvelope1 = rddList.get(0);
    Envelope rddEnvelope2 = rddList.get(1);
    Envelope rddEnvelope3 = rddList.get(2);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd1 = (RemoteDependencyData) ((Data<?>) rddEnvelope1.getData()).getBaseData();
    RemoteDependencyData rdd2 = (RemoteDependencyData) ((Data<?>) rddEnvelope2.getData()).getBaseData();
    RemoteDependencyData rdd3 = (RemoteDependencyData) ((Data<?>) rddEnvelope3.getData()).getBaseData();
    assertEquals("GET /SpringBootTest/asyncDependencyCall", rd.getName());
    assertEquals("200", rd.getResponseCode());
    assertTrue(rd.getProperties().isEmpty());
    assertTrue(rd.getSuccess());
    assertEquals("TestController.asyncDependencyCall", rdd1.getName());
    assertNull(rdd1.getData());
    assertEquals("InProc", rdd1.getType());
    assertNull(rdd1.getTarget());
    assertTrue(rdd1.getProperties().isEmpty());
    assertTrue(rdd1.getSuccess());
    assertEquals("GET /", rdd2.getName());
    assertEquals("https://www.bing.com", rdd2.getData());
    assertEquals("www.bing.com", rdd2.getTarget());
    assertTrue(rdd2.getProperties().isEmpty());
    assertTrue(rdd2.getSuccess());
    // TODO (trask): why is spring-webmvc instrumentation capturing this twice?
    assertEquals("TestController.asyncDependencyCall", rdd3.getName());
    assertTrue(rdd3.getProperties().isEmpty());
    assertTrue(rdd3.getSuccess());
    assertParentChild(rd, rdEnvelope, rddEnvelope1, "GET /SpringBootTest/asyncDependencyCall");
    assertParentChild(rdd1, rddEnvelope1, rddEnvelope2, "GET /SpringBootTest/asyncDependencyCall");
    try {
        assertParentChild(rdd1, rddEnvelope1, rddEnvelope3, "GET /SpringBootTest/asyncDependencyCall");
    } catch (AssertionError e) {
        // on wildfly the duplicate controller spans is nested under the request span for some reason
        assertParentChild(rd, rdEnvelope, rddEnvelope3, "GET /SpringBootTest/asyncDependencyCall");
    }
}
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)65 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)53 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 Data (org.geotoolkit.wps.xml.v200.Data)42 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)26 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)20 IOException (java.io.IOException)16 DataInput (org.geotoolkit.wps.xml.v200.DataInput)15 Format (org.geotoolkit.wps.xml.v200.Format)12 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)10 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 ReferenceProxy (org.geotoolkit.wps.xml.ReferenceProxy)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 DataStoreException (org.apache.sis.storage.DataStoreException)8 LiteralValue (org.geotoolkit.wps.xml.v200.LiteralValue)7 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6