コード例 #1
0
        public void Can_gauge_scalar_value()
        {
            var queue = new Queue<int>();
            var gauge = new Gauge<int>(() => queue.Count);

            queue.Enqueue(5);
            Assert.AreEqual(1, gauge.Value);

            queue.Enqueue(6);
            queue.Dequeue();
            Assert.AreEqual(1, gauge.Value);

            queue.Dequeue();
            Assert.AreEqual(0, gauge.Value);
        }
コード例 #2
0
        public void Can_derive()
        {
            int sum = 0;
            Gauge<int> baseGauge = new Gauge<int>(() => 1);
            DerivativeGauge<int, int> derivativeGauge = new DerivativeGauge<int, int>(baseGauge,
                (x) =>
                { sum += x; return sum; }
                );
            Assert.AreEqual(1, derivativeGauge.Value);
            Assert.AreEqual(2, derivativeGauge.Value);
            Assert.AreEqual(3, derivativeGauge.Value);
            Assert.AreEqual(4, derivativeGauge.Value);
            Assert.AreEqual(4, sum);

        }
コード例 #3
0
 private void reportGauge(long timestamp, MetricName name, Gauge gauge)
 {
     report(timestamp, name, "value", gauge.ValueAsString);
 }
コード例 #4
0
 private void reportGauge(MetricName name, Gauge gauge, long timestamp)
 {
     string value = format(gauge.ValueAsString);
     if (value != null)
     {
         graphite.Send(Prefix(name), value, timestamp);
     }
 }