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); }
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); }
private void reportGauge(long timestamp, MetricName name, Gauge gauge) { report(timestamp, name, "value", gauge.ValueAsString); }
private void reportGauge(MetricName name, Gauge gauge, long timestamp) { string value = format(gauge.ValueAsString); if (value != null) { graphite.Send(Prefix(name), value, timestamp); } }