public void IncrementTest()
 {
     StatsdPipe target = new StatsdPipe(); // TODO: Initialize to an appropriate value
     string[] keys = null; // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     actual = target.Increment(keys);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Example #2
0
 static void SendingWithGeyserStrategy()
 {
     Console.WriteLine("SendingWithGeyserStrategy");
     StatsdPipe statsd = new StatsdPipe();
     statsd.Strategy = new BufferedStrategy(5000);
     while (true)
     {
         Thread.Sleep(1);
         statsd.Increment(bucketPrefix + "mailslot");
     }
 }
Example #3
0
 static void SendMany()
 {
     Console.WriteLine("SendMany");
     DateTime start = DateTime.Now;
     StatsdPipe statsd = new StatsdPipe();
     statsd.Strategy = new BufferedStrategy(5000);
     for (int i = 0; i < 100000000; i++ )
     {
         //Thread.Sleep(1);
         statsd.Increment(bucketPrefix + "mailslot");
     }
     int elapsedTimeMillis = Convert.ToInt32((DateTime.Now - start).TotalMilliseconds);
     Console.WriteLine("Test took: " + elapsedTimeMillis + " msec");
 }
        static void TestMailSlotStreaming()
        {
            GeyserStrategy strategy = new GeyserStrategy();
            strategy.Interval = 2000;

            StatsdPipe statsd = new StatsdPipe();
            statsd.Strategy = strategy;

            for (int i=0; i<1000; i++)
            {
                Thread.Sleep(r.Next(5));
                statsd.Increment(bucketPrefix + "mailslot");
            }
        }
        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");
        }
Example #6
0
 static void SendingWithoutGeyserStrategy()
 {
     Console.WriteLine("SendingWithoutGeyserStrategy");
     StatsdPipe statsd = new StatsdPipe();
     int i = 0;
     StringBuilder sb = new StringBuilder();
     sb.Append("a");
     for (i = 0; i < 10; i++)
     {
         sb.Append(sb.ToString());
     }
     Console.WriteLine(sb.Length);
     statsd.UpdateCount(1, 'a');
     statsd.Strategy = new BufferedStrategy(5000);
     while (true)
     {
         Thread.Sleep(1);
         statsd.Increment(bucketPrefix + "mailslot");
     }
 }
Example #7
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");
                }
            }
        }
 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");
         }
     }
 }
 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();
 }
        static void Main(string[] args)
        {
            StatsdPipe statsd = new StatsdPipe("127.0.0.1", 8126);

            string bucketPrefix = "csharp.test.";

            // These are examples of every function the API offers.
            statsd.Gauge(bucketPrefix + "Gauge", 500);
            statsd.Gauge(bucketPrefix + "Gauge", 500, 2);
            statsd.GaugeWithMessage("GaugeWithMessage(string message, string key, int value)",bucketPrefix + "GaugeWithMessage", 500);
            statsd.GaugeWithMessage("GaugeWithMessage(string message, string key, int value, double samplerate)", bucketPrefix + "GaugeWithMessage", 500, 2);

            statsd.Timing(bucketPrefix + "Timing", 1);
            statsd.Timing(bucketPrefix + "Timing", 1, 2);
            statsd.TimingWithMessage("Timing(string key, int value)", bucketPrefix + "Timing", 1);
            statsd.TimingWithMessage("Timing(string key, int value)", bucketPrefix + "Timing", 2);

            statsd.Decrement(bucketPrefix + "Decrement");
            statsd.Decrement(bucketPrefix + "Decrement", 1);
            statsd.Decrement(bucketPrefix + "Decrement", 1, 2);
            statsd.Decrement(bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");
            statsd.Decrement(1, bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");
            statsd.Decrement(1, 2, bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");

            statsd.DecrementWithMessage("DecrementWithMessage(string message, string key)", bucketPrefix + "DecrementWithMessage");
            statsd.DecrementWithMessage("DecrementWithMessage(string message, string key, int magnitude)", bucketPrefix + "DecrementWithMessage", 1);
            statsd.DecrementWithMessage("DecrementWithMessage(string message, string key, int magnitude, double sampleRate)", bucketPrefix + "DecrementWithMessage", 1, 2);
            statsd.DecrementWithMessage("DecrementWithMessage(string message, params string[] keys)", bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");
            statsd.DecrementWithMessage("DecrementWithMessage(string message, int magnitude, params string[] keys)", 1, bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");
            statsd.DecrementWithMessage("DecrementWithMessage(string message, int magnitude, double sampleRate, params string[] keys)", 1, 2, bucketPrefix + "Dec1", bucketPrefix + "Dec2", bucketPrefix + "Dec3");

            statsd.Increment(bucketPrefix + "Increment");
            statsd.Increment(bucketPrefix + "Increment", 1);
            statsd.Increment(bucketPrefix + "Increment", 1, 2);
            statsd.Increment(bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");
            statsd.Increment(1, bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");
            statsd.Increment(1, 2, bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");

            statsd.IncrementWithMessage("IncrementWithMessage(string message, string key)", bucketPrefix + "IncrementWithMessage");
            statsd.IncrementWithMessage("IncrementWithMessage(string message, string key, int magnitude)", bucketPrefix + "IncrementWithMessage", 1);
            statsd.IncrementWithMessage("IncrementWithMessage(string message, string key, int magnitude, double sampleRate)", bucketPrefix + "IncrementWithMessage", 1, 2);
            statsd.IncrementWithMessage("IncrementWithMessage(string message, params string[] keys)", bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");
            statsd.IncrementWithMessage("IncrementWithMessage(string message, int magnitude, params string[] keys)", 1, bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");
            statsd.IncrementWithMessage("IncrementWithMessage(string message, int magnitude, double sampleRate, params string[] keys)", 1, 2, bucketPrefix + "Inc1", bucketPrefix + "Inc2", bucketPrefix + "Inc3");

            // These are some Special cases.

            statsd.IncrementWithMessage("This bucket starts as an increment...", bucketPrefix + "typechange");

            statsd.TimingWithMessage("This bucket gets changed to a Timer", bucketPrefix + "typechange", 500);

            string bucketnameWithSpace = bucketPrefix + "Spaced Name";

            statsd.IncrementWithMessage("This bucket has a space it its name.", bucketnameWithSpace);

            string bucketnameWithUnicodeSymbols = bucketPrefix + "Unicode√∭∑⍥汉字/漢字Name";

            statsd.IncrementWithMessage("This bucket has unicode characters in its name.", bucketnameWithUnicodeSymbols);

            statsd.IncrementWithMessage("This bucket ends in a '.' ", bucketPrefix);

            string bucketnameWith65Chars = bucketPrefix+"65CharacterBucketName";

            while (bucketnameWith65Chars.Length < 65)
                bucketnameWith65Chars += "A";

            statsd.IncrementWithMessage("This bucket should not be accepted, because it is too long!", bucketnameWith65Chars);

            string bucketnameWithPipe = bucketPrefix + "Piped|Name";

            statsd.IncrementWithMessage("This bucket has a pipe in its name.", bucketnameWithPipe);

            string bucketnameWithColon = bucketPrefix + "Colon:Name";

            statsd.IncrementWithMessage("This bucket has a colon in its name.", bucketnameWithColon);

            statsd.IncrementWithMessage("This bucket should be perfectly acceptable, but comes after some unacceptable names.", bucketPrefix + "acceptableName");
        }