Ejemplo n.º 1
0
        public void ConstructWithoutProvider()
        {
            //check to make sure the constructor doesn't blow
            var t = new Statsd(new StatsdOptions()
            {
                OnExceptionGenerated = (exception) => { throw exception; }
            });

            t.CountAsync("awesome").GetAwaiter().GetResult();
            t.Dispose();
        }
Ejemplo n.º 2
0
        public void ConfirmMetricsNotBuffered()
        {
            var mockedMetric = new Mock <NullChannel>();

            mockedMetric.Setup(a => a.IsConnected).Returns(true);
            mockedMetric.Setup(a => a.SendAsync(It.Is <byte[]>(param => param.Length < 50))).Verifiable();
            using (var statsd = new Statsd(new StatsdOptions()
            {
            }, mockedMetric.Object))
            {
                for (int i = 0; i < 100000; i++)
                {
                    statsd.CountAsync("fun");
                }
                while (mockedMetric.Object.worker.IsBusy)
                {
                }
                mockedMetric.Verify();
            }
        }
Ejemplo n.º 3
0
        public void ConfirmUdpSendNoBufferedTime()
        {
            var client = new Udp();

            using (var statsd = new Statsd(new StatsdOptions()
            {
                BufferMetrics = false, OnExceptionGenerated = (exception) => { throw exception; }
            }, client))
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();
                for (int i = 0; i < 100000; i++)
                {
                    statsd.CountAsync("fun");
                }
                while (client.worker.IsBusy)
                {
                }
                stopwatch.Stop();
                //we shouldn't cost more than 1 milisecond a metric buffered or not
                Assert.InRange(stopwatch.ElapsedMilliseconds, 0, 100000);
            }
        }