public void SamplingRoutesExcludedTypes()
        {
            var unsampled = new AdaptiveTesterMessageSink();
            var sampled   = new AdaptiveTesterMessageSink();
            SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled, sampled);

            sampler.ExcludedTypes      = "Request";
            sampler.SamplingPercentage = 100.0;

            sampler.Process(new RequestTelemetry());
            sampler.Process(new EventTelemetry());

            Assert.IsNotNull(sampled.events.Dequeue());
            Assert.IsNotNull(unsampled.requests.Dequeue());
        }
Пример #2
0
        public void EarlyExitWhenProcessingAt100Percent()
        {
            var sentTelemetry = new List <ITelemetry>();
            var processor     = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null)
            {
                OnProcess = t => sentTelemetry.Add(t)
            })
            {
                SamplingPercentage = 100.0
            };

            processor.Process(new RequestTelemetry());

            Assert.IsFalse(((ISupportSampling)sentTelemetry[0]).SamplingPercentage.HasValue);
        }
Пример #3
0
        public void AllTelemetryIsSentWithDefaultSamplingRate()
        {
            var sentTelemetry = new List <ITelemetry>();
            var processor     = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null)
            {
                OnProcess = t => sentTelemetry.Add(t)
            });

            const int ItemsToGenerate = 100;

            for (int i = 0; i < ItemsToGenerate; i++)
            {
                processor.Process(new RequestTelemetry());
            }

            Assert.AreEqual(ItemsToGenerate, sentTelemetry.Count);
        }
Пример #4
0
        public void TelemetryItemHasSamplingPercentageSet()
        {
            var sentTelemetry = new List <ITelemetry>();
            var processor     = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null)
            {
                OnProcess = t => sentTelemetry.Add(t)
            });

            processor.SamplingPercentage = 20;

            do
            {
                processor.Process(new RequestTelemetry());
            }while (sentTelemetry.Count == 0);

            Assert.Equal(20, ((ISupportSampling)sentTelemetry[0]).SamplingPercentage);
        }
Пример #5
0
        public void TelemetryItemSamplingIsSkippedWhenSetByUser()
        {
            var sentTelemetry = new List <ITelemetry>();
            var processor     = new SamplingTelemetryProcessor(new StubTelemetryProcessor(null)
            {
                OnProcess = t => sentTelemetry.Add(t)
            })
            {
                SamplingPercentage = 0
            };

            var requestTelemetry = new RequestTelemetry();

            ((ISupportSampling)requestTelemetry).SamplingPercentage = 100;
            processor.Process(requestTelemetry);

            Assert.AreEqual(1, sentTelemetry.Count);
        }
        public void SamplingWontEarlyExitWhenUnsampledNextPresent()
        {
            var unsampled = new AdaptiveTesterMessageSink();
            var sampled   = new AdaptiveTesterMessageSink();
            SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled, sampled)
            {
                SamplingPercentage = 100.0
            };

            sampler.Process(new RequestTelemetry());
            Assert.IsTrue(sampled.requests.Count == 1);
            var sent = sampled.requests.Dequeue();

            Assert.IsNotNull(sent);
            var sentSample = sent as ISupportSampling;

            Assert.IsNotNull(sentSample);
            Assert.IsTrue(sentSample.SamplingPercentage.HasValue);
        }
        public void SamplingSkipsSampledTelemetryItemProperty()
        {
            var unsampled = new AdaptiveTesterMessageSink();
            var sampled   = new AdaptiveTesterMessageSink();
            SamplingTelemetryProcessor sampler = new SamplingTelemetryProcessor(unsampled, sampled)
            {
                SamplingPercentage = 100.0
            };

            var send        = new RequestTelemetry();
            var sendSampled = (send as ISupportSampling);

            Assert.IsNotNull(sendSampled);
            sendSampled.SamplingPercentage = 25.0;

            sampler.Process(send);

            Assert.IsTrue(unsampled.requests.Count == 1);
            Assert.IsTrue(sampled.requests.Count == 0);
        }