Exemplo n.º 1
0
        public async Task CanIncrementCounter()
        {
            var metrics = new InMemoryMetricsClient();

            await metrics.CounterAsync("c1");

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

            await metrics.CounterAsync("c1", 5);

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

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

            Assert.True(counter.Rate > 400);

            await metrics.GaugeAsync("g1", 2.534);

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

            await metrics.TimerAsync("t1", 50788);

            var stats = metrics.GetMetricStats();

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

            metrics.DisplayStats(_writer);
        }