Search in sources :

Example 1 with DataPoint

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

the class CoreAndFilterTests method trackMetric.

@Test
@TargetUri("/trackMetric")
public void trackMetric() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> mdList = mockedIngestion.waitForItems("MetricData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope mdEnvelope = mdList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    MetricData md = (MetricData) ((Data<?>) mdEnvelope.getData()).getBaseData();
    List<DataPoint> metrics = md.getMetrics();
    assertEquals(1, metrics.size());
    DataPoint dp = metrics.get(0);
    final double expectedValue = 111222333.0;
    double epsilon = Math.ulp(expectedValue);
    assertEquals(DataPointType.Measurement, dp.getKind());
    assertEquals(expectedValue, dp.getValue(), epsilon);
    assertEquals("TimeToRespond", dp.getName());
    assertNull("getCount was non-null", dp.getCount());
    assertNull("getMin was non-null", dp.getMin());
    assertNull("getMax was non-null", dp.getMax());
    assertNull("getStdDev was non-null", dp.getStdDev());
    assertParentChild(rd, rdEnvelope, mdEnvelope, "GET /CoreAndFilter/trackMetric");
}
Also used : DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint) RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Test(org.junit.Test)

Example 2 with DataPoint

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

the class MicrometerTest method doMostBasicTest.

@Test
@TargetUri("/test")
public void doMostBasicTest() throws Exception {
    Telemetry telemetry = getTelemetry(0);
    assertEquals("GET /test", telemetry.rd.getName());
    assertTrue(telemetry.rd.getUrl().matches("http://localhost:[0-9]+/test"));
    assertEquals("200", telemetry.rd.getResponseCode());
    assertTrue(telemetry.rd.getSuccess());
    assertNull(telemetry.rd.getSource());
    assertTrue(telemetry.rd.getProperties().isEmpty());
    assertTrue(telemetry.rd.getMeasurements().isEmpty());
    // sleep a bit and make sure that the excluded metric is not reported
    Thread.sleep(10000);
    List<Envelope> metricItems = mockedIngestion.getItemsEnvelopeDataType("MetricData").stream().filter(e -> {
        MetricData data = (MetricData) ((Data<?>) e.getData()).getBaseData();
        List<DataPoint> points = data.getMetrics();
        DataPoint point = points.get(0);
        return point.getValue() == 1;
    }).collect(Collectors.toList());
    MetricData data = (MetricData) ((Data<?>) metricItems.get(0).getData()).getBaseData();
    List<DataPoint> points = data.getMetrics();
    assertEquals(1, points.size());
    DataPoint point = points.get(0);
    assertEquals(DataPointType.Measurement, point.getKind());
    // (this was verified above in Predicate also)
    assertEquals(1, point.getValue(), 0);
    assertEquals("test_counter", point.getName());
    assertNull("getCount was non-null", point.getCount());
    assertNull("getMin was non-null", point.getMin());
    assertNull("getMax was non-null", point.getMax());
    assertNull("getStdDev was non-null", point.getStdDev());
    assertEquals(1, data.getProperties().size());
    assertEquals("value1", data.getProperties().get("tag1"));
}
Also used : List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Assert.assertTrue(org.junit.Assert.assertTrue) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) Test(org.junit.Test) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint) Collectors(java.util.stream.Collectors) Assert.assertEquals(org.junit.Assert.assertEquals) DataPointType(com.microsoft.applicationinsights.smoketest.schemav2.DataPointType) DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) List(java.util.List) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) MetricData(com.microsoft.applicationinsights.smoketest.schemav2.MetricData) Test(org.junit.Test)

Example 3 with DataPoint

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

the class PerfCountersDataTest method assertPerfMetric.

private void assertPerfMetric(MetricData perfMetric) {
    List<DataPoint> metrics = perfMetric.getMetrics();
    assertEquals(1, metrics.size());
    DataPoint dp = metrics.get(0);
    assertEquals(DataPointType.Measurement, dp.getKind());
}
Also used : DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)

Aggregations

DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)3 Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)2 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)2 Test (org.junit.Test)2 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)1 DataPointType (com.microsoft.applicationinsights.smoketest.schemav2.DataPointType)1 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1