Exemplo n.º 1
0
        static void ShowExample()
        {
            StatsdPipe statsd = new StatsdPipe();

            statsd.Gauge(bucketPrefix + "gauge", 500);
            statsd.Gauge("Gauge(string message, string key, int value)", bucketPrefix + "gauge", 500);
            statsd.Timing(bucketPrefix + "timer", 500);
            statsd.Timing("Timer(string message, string key, int value)", bucketPrefix + "timer", 500);
            statsd.Increment(bucketPrefix + "counter");
            statsd.Decrement(bucketPrefix + "counter");
            statsd.UpdateCount(2, bucketPrefix + "counter");
            statsd.UpdateCount(3, 0, bucketPrefix + "counter", bucketPrefix + "counter2");
            statsd.UpdateCount(4, 2, bucketPrefix + "counter", bucketPrefix + "counter2");
            statsd.UpdateCount("UpdateCount(string message, string key, int value)", 5, bucketPrefix + "counter", bucketPrefix + "counter2");
            statsd.UpdateCount("UpdateCount(string message, string key, int value)", 6, 1, bucketPrefix + "counter");
        }
Exemplo n.º 2
0
        static void TestUnderPressure()
        {
            Console.WriteLine("TestUnderPressure");
            StatsdPipe statsd = new StatsdPipe();

            statsd.Transport = new TransportMock();
            statsd.Strategy  = new BufferedStrategy(500);

            statsd.Increment(bucketPrefix + "pressure.multiple1");
            try
            {
                statsd.Gauge(bucketPrefix + "pressure.multiple1", 1);
            }
            catch (BucketTypeMismatchException btme)
            {
                Console.WriteLine(btme.Message);
            }

            for (int i = 0; i < 1000000; i++)
            {
                DateTime start = DateTime.Now;
                statsd.Increment(bucketPrefix + "pressure.multiple1");
                int elapsedTimeMillis = Convert.ToInt32((DateTime.Now - start).TotalMilliseconds);
                statsd.Timing(bucketPrefix + "pressure.incr_time", elapsedTimeMillis);
                if (i % 3 == 0)
                {
                    statsd.Increment(bucketPrefix + "pressure.multiple3");
                }
            }
        }
Exemplo n.º 3
0
        public void TimingTest1()
        {
            StatsdPipe target   = new StatsdPipe(); // TODO: Initialize to an appropriate value
            string     key      = string.Empty;     // TODO: Initialize to an appropriate value
            int        value    = 0;                // TODO: Initialize to an appropriate value
            bool       expected = false;            // TODO: Initialize to an appropriate value
            bool       actual;

            actual = target.Timing(key, value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Exemplo n.º 4
0
        static void TestUnderPressure()
        {
            StatsdPipe statsd = new StatsdPipe();

            statsd.Send = new TransportMock().Send;
            GeyserStrategy stra = new GeyserStrategy();

            stra.Interval   = 0.5;
            statsd.Strategy = stra;
            for (int i = 0; i < 10000; i++)
            {
                DateTime start = DateTime.Now;
                statsd.Increment(bucketPrefix + "pressure.multiple1");
                int elapsedTimeMillis = Convert.ToInt32((DateTime.Now - start).TotalMilliseconds);
                statsd.Timing(bucketPrefix + "pressure.incr_time", elapsedTimeMillis);
                if (i % 3 == 0)
                {
                    statsd.Increment(bucketPrefix + "pressure.multiple3");
                }
            }
        }
Exemplo n.º 5
0
        public void ThreadPoolCallback(Object threadContext)
        {
            StatsdPipe statsd = new StatsdPipe();

            statsd.Send = new TransportMock().Send;
            GeyserStrategy stra = new GeyserStrategy();

            stra.Interval   = 0.5;
            statsd.Strategy = stra;
            int threadIndex = (int)threadContext;

            for (int i = 0; i < 100; i++)
            {
                //Thread.Sleep(r.Next(5));
                DateTime start = DateTime.Now;
                statsd.Increment(bucketPrefix + "threadpool.thread" + threadIndex);
                int elapsedTimeMillis = Convert.ToInt32((DateTime.Now - start).TotalMilliseconds);
                statsd.Timing(bucketPrefix + "threadpool.incr_time", elapsedTimeMillis);
            }
            doneEvent.Set();
        }
        public void SendMessageStats(Glmps.Message.ITimelineMessage message, ITabSetupContext context = null)
        {
            if (message is StatsdNetMessage)
            {
                return;
            }

            var timer     = InitializeTimer(message);
            var selfTimer = Stopwatch.StartNew();

            string statKey = GenerateStatKey(message);

            StatsdPipe.Timing(statKey, (long)message.Duration.TotalMilliseconds);

            IncrementStoredCount(statKey, context);

            selfTimer.Stop();

            timer.Duration = selfTimer.Elapsed;
            PublishTimingMessage(timer, message, context);

            IncrementStoredCount("StatsdNet.TimingSum", context, timer.Duration.TotalMilliseconds);
            StatsdPipe.Timing("GlimpseStatsdNetTiming", (long)timer.Duration.TotalMilliseconds);
        }