Esempio n. 1
0
        public void OnNewValue()
        {
            var handler    = new BufferBuilderHandlerMock();
            var aggregator = new GaugeAggregator(MetricAggregatorParametersFactory.Create(handler.Object));

            AddStatsMetric(aggregator, "s1", 1);
            AddStatsMetric(aggregator, "s1", 2);
            AddStatsMetric(aggregator, "s2", 3);
            aggregator.TryFlush(force: true);

            Assert.AreEqual("s1:2|g|@0,s2:3|g|@0", handler.Value);
        }
Esempio n. 2
0
        public void Pool()
        {
            var handler    = new BufferBuilderHandlerMock();
            var parameters = MetricAggregatorParametersFactory.Create(handler.Object, TimeSpan.FromMinutes(1), 1);
            var aggregator = new SetAggregator(parameters, null);

            // Check StatsMetricSet instance go back to the pool
            for (int i = 0; i < 10; ++i)
            {
                AddStatsMetric(aggregator, "s1", i.ToString());
                Assert.AreEqual($"s1:{i}|s|@0", handler.Value);
            }
        }
Esempio n. 3
0
        public void OnNewValue()
        {
            var handler    = new BufferBuilderHandlerMock();
            var aggregator = new SetAggregator(MetricAggregatorParametersFactory.Create(handler.Object), null);

            AddStatsMetric(aggregator, "s1", "1");
            AddStatsMetric(aggregator, "s1", "2");
            AddStatsMetric(aggregator, "s1", "2");
            AddStatsMetric(aggregator, "s1", "2");
            AddStatsMetric(aggregator, "s2", "3");
            aggregator.TryFlush(force: true);
            Assert.AreEqual("s1:1|s|@0,s1:2|s|@0,s2:3|s|@0", handler.Value);

            AddStatsMetric(aggregator, "s1", "4");
            aggregator.TryFlush(force: true);
            Assert.AreEqual("s1:4|s|@0", handler.Value);
        }