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); }
public async Task CanSetGaugesAsync() { await _metricsClient.GaugeAsync("mygauge", 12d); Assert.Equal(12d, _metricsClient.GetGaugeValue("mygauge")); await _metricsClient.GaugeAsync("mygauge", 10d); await _metricsClient.GaugeAsync("mygauge", 5d); await _metricsClient.GaugeAsync("mygauge", 4d); await _metricsClient.GaugeAsync("mygauge", 12d); await _metricsClient.GaugeAsync("mygauge", 20d); Assert.Equal(20d, _metricsClient.GetGaugeValue("mygauge")); _metricsClient.DisplayStats(); }