コード例 #1
0
        public void CanIncrementCounter()
        {
            var metrics = new InMemoryMetricsClient();

            metrics.Counter("c1");
            Assert.Equal(1, metrics.GetCount("c1"));

            metrics.Counter("c1", 5);
            Assert.Equal(6, metrics.GetCount("c1"));

            var counter = metrics.Counters["c1"];

            Assert.True(counter.Rate > 400);

            metrics.Gauge("g1", 2.534);
            Assert.Equal(2.534, metrics.GetGaugeValue("g1"));

            metrics.Timer("t1", 50788);
            var stats = metrics.GetMetricStats();

            Assert.Equal(1, stats.Timings.Count);

            metrics.DisplayStats(_writer);
        }