Esempio n. 1
0
        public void Can_get_same_metric_when_metric_exists()
        {
            // var metrics = new Metrics();
            var counter = registry.Counter("CounterTests.Can_get_same_metric_when_metric_exists");

            Assert.IsNotNull(counter);

            var same = registry.Counter("CounterTests.Can_get_same_metric_when_metric_exists");

            Assert.AreSame(counter, same);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var db1Metrics = new MetricRegistry();
            var reporter   = ConsoleReporter.ForRegistry(db1Metrics).build();
            var meter      = db1Metrics.Meter("testMeter");
            var randomHist = db1Metrics.Histogram("testHist");
            //var machineMetrics = MachineMetrics.Create(MachineMetricsCategory.All);
            //db1Metrics.Register("MachineMetrics", machineMetrics);

            //reporter.Start(1, TimeUnit.Seconds);
            CsvReporter creporter = CsvReporter.forRegistry(db1Metrics).build("c:\\merchlog");
            //creporter.Start(1, TimeUnit.Seconds);

            Graphite         sender    = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(db1Metrics).Build(sender);

            greporter.Start(10, TimeUnit.Seconds);



            //var docsTimedCounterPerSec = db1Metrics.TimedCounter("db1", "docs new indexed/sec", "new Indexed Documents");
            int i = 0;

            db1Metrics.Gauge <int>("testGauge", () => i);
            Random r       = new Random();
            var    counter = db1Metrics.Counter("testCounter");

            for (; i < 10000; i++)
            {
                meter.Mark();
                counter.Increment(i);
                randomHist.Update(r.Next(101));
                Thread.Sleep(100);
            }
            Console.WriteLine("Done counting");
            for (i = 0; i < 10; i++)
            {
                Thread.Sleep(60000);
            }


            //Console.WriteLine(docsTimedCounterPerSec.CurrentValue);

            /*var RequestsPerSecondHistogram = db1Metrics.Histogram("db1.Request Per Second Histogram");
             * for (int i = 0; i < 100; i++)
             * {
             *  RequestsPerSecondCounter.Mark();
             *  RequestsPerSecondHistogram.Update((long)RequestsPerSecondCounter.CurrentValue);
             *  Thread.Sleep(10);
             * }
             * StringBuilder sb = new StringBuilder();
             * double[] res;
             * var perc = RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
             * res = perc;
             * RequestsPerSecondHistogram.LogJson(sb,perc);
             * Console.WriteLine(sb);
             * Console.WriteLine(RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999));
             * // RequestsPerSecondHistogram.Update((long)documentDatabase.WorkContext.MetricsCounters.RequestsPerSecondCounter.CurrentValue); //??
             */
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            var db1Metrics = new MetricRegistry();
            var reporter = ConsoleReporter.ForRegistry(db1Metrics).build();
            var meter = db1Metrics.Meter("testMeter");
            var randomHist = db1Metrics.Histogram("testHist");
            //var machineMetrics = MachineMetrics.Create(MachineMetricsCategory.All);
            //db1Metrics.Register("MachineMetrics", machineMetrics);

            //reporter.Start(1, TimeUnit.Seconds);
            CsvReporter creporter = CsvReporter.forRegistry(db1Metrics).build("c:\\merchlog");
            //creporter.Start(1, TimeUnit.Seconds);

            Graphite sender = new Graphite("ttolley-lap3", 2003);
            GraphiteReporter greporter = GraphiteReporter.ForRegistry(db1Metrics).Build(sender);
            greporter.Start(10, TimeUnit.Seconds);




            //var docsTimedCounterPerSec = db1Metrics.TimedCounter("db1", "docs new indexed/sec", "new Indexed Documents");
            int i = 0;
            db1Metrics.Gauge<int>("testGauge", () => i);
            Random r = new Random();
            var counter = db1Metrics.Counter("testCounter");
            for (; i < 10000; i++)
            {
                meter.Mark();
                counter.Increment(i);
                randomHist.Update(r.Next(101));
                Thread.Sleep(100);

            }
            Console.WriteLine("Done counting");
            for(i=0;i<10;i++)
            {
                Thread.Sleep(60000);
            }

            
            //Console.WriteLine(docsTimedCounterPerSec.CurrentValue);

            /*var RequestsPerSecondHistogram = db1Metrics.Histogram("db1.Request Per Second Histogram");
            for (int i = 0; i < 100; i++)
            {
                RequestsPerSecondCounter.Mark();
                RequestsPerSecondHistogram.Update((long)RequestsPerSecondCounter.CurrentValue);
                Thread.Sleep(10);
            }
            StringBuilder sb = new StringBuilder();
            double[] res;
            var perc = RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999);
            res = perc;
            RequestsPerSecondHistogram.LogJson(sb,perc);
            Console.WriteLine(sb);
            Console.WriteLine(RequestsPerSecondHistogram.Percentiles(0.5, 0.75, 0.95, 0.98, 0.99, 0.999));
           // RequestsPerSecondHistogram.Update((long)documentDatabase.WorkContext.MetricsCounters.RequestsPerSecondCounter.CurrentValue); //??
           */
        }
Esempio n. 4
0
        public void Can_dec_multiple()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var counter = _metrics.Counter("CounterTests.Can_count");
            Assert.IsNotNull(counter);

            counter.Decrement(8);
            Assert.AreEqual(-8, counter.Count);
        }
Esempio n. 5
0
        public void Can_inc()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var counter = _metrics.Counter("CounterTests.Can_count");
            Assert.IsNotNull(counter);

            counter.Increment();
            Assert.AreEqual(1, counter.Count);
        }
Esempio n. 6
0
        public void Can_inc_multiple()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var            counter  = _metrics.Counter("CounterTests.Can_count");

            Assert.IsNotNull(counter);

            counter.Increment(100);
            Assert.AreEqual(100, counter.Count);
        }
Esempio n. 7
0
        public void Can_dec()
        {
            MetricRegistry _metrics = new MetricRegistry();
            var            counter  = _metrics.Counter("CounterTests.Can_count");

            Assert.IsNotNull(counter);

            counter.Decrement();
            Assert.AreEqual(-1, counter.Count);
        }
Esempio n. 8
0
 public override IInterceptor CreateInterceptor(IProxyRequest request)
 {
     if (interceptor == null)
     {
         MetricName     metricName = Utils.BuildName(request, Name, Absolute);
         MetricRegistry registry   = request.Context.Kernel.Get <MetricRegistry>();
         Counter        counter    = registry.Counter(metricName);
         interceptor = new CountingInterceptor(counter, Monotonic);
     }
     return(interceptor);
 }