コード例 #1
0
        public void MetricNameIsUsedForCounter()
        {
            var tags = new Dictionary <string, string> {
                { "foo", "bar" }
            };

            InMemoryMetricsFactory inMemoryMetricsFactory = new InMemoryMetricsFactory();

            inMemoryMetricsFactory.CreateCounter("thecounter", tags);

            Assert.Equal(-1, inMemoryMetricsFactory.GetCounter("thecounter", new Dictionary <string, string>()));
            Assert.Equal(0, inMemoryMetricsFactory.GetCounter("thecounter", tags));
        }
コード例 #2
0
        public void CounterValueIsIncreased()
        {
            var tags = new Dictionary <string, string> {
                { "foo", "bar" }
            };

            InMemoryMetricsFactory inMemoryMetricsFactory = new InMemoryMetricsFactory();
            ICounter counter = inMemoryMetricsFactory.CreateCounter("thecounter", tags);

            Assert.Equal(0, inMemoryMetricsFactory.GetCounter("thecounter", tags));

            counter.Inc(1);

            Assert.Equal(1, inMemoryMetricsFactory.GetCounter("thecounter", tags));
        }