Esempio n. 1
0
        public void reportHistogram_simpleHistogram_addedAllStats()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportHistogram", "testhistogram", histogram(1000, 1.0, "", 2.0, "", 1.1, 0.1, "", 0.2, 1.1, 1.3, 1.8, 1.9, 2.0, 2.0), Unit.Items, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(12, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testhistogram.count", 1000L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testhistogram.last", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testhistogram.min", 0.1, "")));
            Assert.IsTrue(PointsEqual(points[3], GetDataPoint("testhistogram.avg", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[4], GetDataPoint("testhistogram.max", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[5], GetDataPoint("testhistogram.stdDev", 0.2, "")));
            Assert.IsTrue(PointsEqual(points[6], GetDataPoint("testhistogram.median", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[7], GetDataPoint("testhistogram.75percentile", 1.3, "")));
            Assert.IsTrue(PointsEqual(points[8], GetDataPoint("testhistogram.95percentile", 1.8, "")));
            Assert.IsTrue(PointsEqual(points[9], GetDataPoint("testhistogram.98percentile", 1.9, "")));
            Assert.IsTrue(PointsEqual(points[10], GetDataPoint("testhistogram.99percentile", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[11], GetDataPoint("testhistogram.999percentile", 2.0, "")));
        }
Esempio n. 2
0
        public void reportMeter_meterWithSetItems_addedSetItems()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportMeter", "testmeter", meter(500, 1.0, 60.0, 300.0, 900.0, new MeterValue.SetItem[] {
                new MeterValue.SetItem("testitem", 60.0, meter(300, 1.0, 60.0, 300.0, 900.0))
            }), Unit.Items, TimeUnit.Seconds, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(11, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testmeter.count", 500L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testmeter.avg", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testmeter.1m", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[3], GetDataPoint("testmeter.5m", 300.0, "")));
            Assert.IsTrue(PointsEqual(points[4], GetDataPoint("testmeter.15m", 900.0, "")));
            Assert.IsTrue(PointsEqual(points[5], GetDataPoint("testmeter.testitem.count", 300L, "")));
            Assert.IsTrue(PointsEqual(points[6], GetDataPoint("testmeter.testitem.percent", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[7], GetDataPoint("testmeter.testitem.avg", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[8], GetDataPoint("testmeter.testitem.1m", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[9], GetDataPoint("testmeter.testitem.5m", 300.0, "")));
            Assert.IsTrue(PointsEqual(points[10], GetDataPoint("testmeter.testitem.15m", 900.0, "")));
        }
Esempio n. 3
0
        public void reportGauge_simpleGauge_addedGauge()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportGauge", "testgauge", gauge(1.0), Unit.Items, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(1, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testgauge", 1.0, "")));
        }
Esempio n. 4
0
        public void reportGauge_reporterWithPrefix_attachedPrefix()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234", "app");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportGauge", "testgauge", 1.0, Unit.Items, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(1, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("app.testgauge", 1.0, "")));
        }
Esempio n. 5
0
        public void reportGauge_gaugeWithTags_attachedTags()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportGauge", "testgauge", 1.0, Unit.Items, new MetricTags(new string[] { "testKey:testValue" }));

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(1, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testgauge", 1.0, "testKey:testValue")));
        }
Esempio n. 6
0
        public void reportCounter_counterWithSetItems_addedSetItems()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportCounter", "testcounter", counter(1, new CounterValue.SetItem[] {
                new CounterValue.SetItem("testitem", 1, 100.0)
            }), Unit.Items, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(3, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testcounter.total", 1L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testcounter.testitem", 1L, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testcounter.testitem.percent", 100.0, "")));
        }
Esempio n. 7
0
        public void reportMeter_simpleMeter_addedAllStats()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");

            // Act
            telegrafReport.call("ReportMeter", "testmeter", meter(500, 1.0, 60.0, 300.0, 900.0), Unit.Items, TimeUnit.Seconds, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(5, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testmeter.count", 500L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testmeter.avg", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testmeter.1m", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[3], GetDataPoint("testmeter.5m", 300.0, "")));
            Assert.IsTrue(PointsEqual(points[4], GetDataPoint("testmeter.15m", 900.0, "")));
        }
Esempio n. 8
0
        public void reportTimer_simpleTimer_addedAllStats()
        {
            // Arrange
            TelegrafReport telegrafReport = new TelegrafReport("udp://localhost:1234");

            telegrafReport.call("StartContext", "");
            TimerValue timer = this.timer(meter(1000, 1.0, 60.0, 300.0, 900.0),
                                          histogram(1000, 1.0, "", 2.0, "", 1.1, 0.1, "", 0.2, 1.1, 1.3, 1.8, 1.9, 2.0, 2.0),
                                          5,
                                          1100);

            // Act
            telegrafReport.call("ReportTimer", "testtimer", timer, Unit.Items, TimeUnit.Seconds, TimeUnit.Seconds, new MetricTags());

            // Assert
            List <LineProtocolPoint> points = GetDataPoints(telegrafReport);

            Assert.AreEqual(19, points.Count);
            Assert.IsTrue(PointsEqual(points[0], GetDataPoint("testtimer.rate.count", 1000L, "")));
            Assert.IsTrue(PointsEqual(points[1], GetDataPoint("testtimer.rate.avg", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[2], GetDataPoint("testtimer.rate.1m", 60.0, "")));
            Assert.IsTrue(PointsEqual(points[3], GetDataPoint("testtimer.rate.5m", 300.0, "")));
            Assert.IsTrue(PointsEqual(points[4], GetDataPoint("testtimer.rate.15m", 900.0, "")));
            Assert.IsTrue(PointsEqual(points[5], GetDataPoint("testtimer.count", 1000L, "")));
            Assert.IsTrue(PointsEqual(points[6], GetDataPoint("testtimer.last", 1.0, "")));
            Assert.IsTrue(PointsEqual(points[7], GetDataPoint("testtimer.min", 0.1, "")));
            Assert.IsTrue(PointsEqual(points[8], GetDataPoint("testtimer.avg", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[9], GetDataPoint("testtimer.max", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[10], GetDataPoint("testtimer.stdDev", 0.2, "")));
            Assert.IsTrue(PointsEqual(points[11], GetDataPoint("testtimer.median", 1.1, "")));
            Assert.IsTrue(PointsEqual(points[12], GetDataPoint("testtimer.75percentile", 1.3, "")));
            Assert.IsTrue(PointsEqual(points[13], GetDataPoint("testtimer.95percentile", 1.8, "")));
            Assert.IsTrue(PointsEqual(points[14], GetDataPoint("testtimer.98percentile", 1.9, "")));
            Assert.IsTrue(PointsEqual(points[15], GetDataPoint("testtimer.99percentile", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[16], GetDataPoint("testtimer.999percentile", 2.0, "")));
            Assert.IsTrue(PointsEqual(points[17], GetDataPoint("testtimer.sessions", 5L, "")));
            Assert.IsTrue(PointsEqual(points[18], GetDataPoint("testtimer.total", 1100L, "")));
        }