public void QuickPulseTelemetryProcessorFiltersOutDependencyCallsToDefaultQuickPulseServiceEndpointInIdleMode()
        {
            // ARRANGE
            var simpleTelemetryProcessorSpy = new SimpleTelemetryProcessorSpy();
            var telemetryProcessor          = new QuickPulseTelemetryProcessor(simpleTelemetryProcessorSpy);

            // ACT
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Name = "http://microsoft.ru"
            });
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Name = "http://rt.services.visualstudio.com/blabla"
            });
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Name = "https://bing.com"
            });

            // ASSERT
            Assert.AreEqual(2, simpleTelemetryProcessorSpy.ReceivedCalls);
            Assert.AreEqual("http://microsoft.ru", (simpleTelemetryProcessorSpy.ReceivedItems[0] as DependencyTelemetry).Name);
            Assert.AreEqual("https://bing.com", (simpleTelemetryProcessorSpy.ReceivedItems[1] as DependencyTelemetry).Name);
        }
        public void QuickPulseTelemetryProcessorIgnoresTelemetryItemsToDifferentInstrumentationKeys()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some other ikey" }
            });
            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(1, accumulatorManager.CurrentDataAccumulator.AIRequestCount);
        }
        public void QuickPulseTelemetryProcessorStopsCollection()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());
            var endpoint           = new Uri("http://microsoft.com");
            var config             = new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            };

            // ACT
            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(accumulatorManager, endpoint, config);
            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StopCollection();
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(1, accumulatorManager.CurrentDataAccumulator.AIRequestCount);
            Assert.AreEqual(0, accumulatorManager.CurrentDataAccumulator.AIDependencyCallCount);
        }
        public void QuickPulseTelemetryProcessorKeepsAccurateCountOfExceptions()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(3, accumulatorManager.CurrentDataAccumulator.AIExceptionCount);
        }
Beispiel #5
0
        public void QuickPulseTelemetryModuleCollectsData()
        {
            // ARRANGE
            var pause    = TimeSpan.FromMilliseconds(100);
            var interval = TimeSpan.FromMilliseconds(1);
            var timings  = new QuickPulseTimings(interval, interval);
            var collectionTimeSlotManager = new QuickPulseCollectionTimeSlotManagerMock(timings);
            var serviceClient             = new QuickPulseServiceClientMock {
                ReturnValueFromPing = true, ReturnValueFromSubmitSample = true
            };
            var performanceCollector = new PerformanceCollectorMock();

            var module             = new QuickPulseTelemetryModule(collectionTimeSlotManager, null, serviceClient, performanceCollector, timings);
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            telemetryProcessor.Initialize(new TelemetryConfiguration());
            module.RegisterTelemetryProcessor(telemetryProcessor);

            // ACT
            module.Initialize(new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            Thread.Sleep(pause);

            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            Thread.Sleep(pause);

            Assert.AreEqual(1, serviceClient.PingCount);

            // ASSERT
            serviceClient.ReturnValueFromPing         = false;
            serviceClient.ReturnValueFromSubmitSample = false;

            Thread.Sleep(pause);
            Assert.IsTrue(serviceClient.SnappedSamples.Count > 0);

            Assert.IsTrue(serviceClient.SnappedSamples.Any(s => s.AIRequestsPerSecond > 0));
            Assert.IsTrue(serviceClient.SnappedSamples.Any(s => s.AIDependencyCallsPerSecond > 0));
            Assert.IsTrue(
                serviceClient.SnappedSamples.Any(
                    s => Math.Abs(s.PerfCountersLookup[@"\ASP.NET Applications(__Total__)\Requests In Application Queue"]) > double.Epsilon));
        }
        public void QuickPulseTelemetryProcessorKeepsAccurateCountOfDependencies()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Success = true, Duration = TimeSpan.FromSeconds(1), Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Success = true, Duration = TimeSpan.FromSeconds(1), Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Success = false, Duration = TimeSpan.FromSeconds(2), Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Success = null, Duration = TimeSpan.FromSeconds(3), Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(4, accumulatorManager.CurrentDataAccumulator.AIDependencyCallCount);
            Assert.AreEqual(1 + 1 + 2 + 3, TimeSpan.FromTicks(accumulatorManager.CurrentDataAccumulator.AIDependencyCallDurationInTicks).TotalSeconds);
            Assert.AreEqual(2, accumulatorManager.CurrentDataAccumulator.AIDependencyCallSuccessCount);
            Assert.AreEqual(1, accumulatorManager.CurrentDataAccumulator.AIDependencyCallFailureCount);
        }
        public void QuickPulseTelemetryProcessorFiltersOutDependencyCallsToQuickPulseServiceDuringCollection()
        {
            // ARRANGE
            var accumulatorManager          = new QuickPulseDataAccumulatorManager();
            var simpleTelemetryProcessorSpy = new SimpleTelemetryProcessorSpy();
            var telemetryProcessor          = new QuickPulseTelemetryProcessor(simpleTelemetryProcessorSpy);
            var config = new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            };

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("https://qps.cloudapp.net/endpoint.svc"),
                config);

            // ACT
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Name = "http://microsoft.ru", Context = { InstrumentationKey = config.InstrumentationKey }
            });
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Name = "http://qps.cloudapp.net/blabla", Context = { InstrumentationKey = config.InstrumentationKey }
            });
            telemetryProcessor.Process(
                new DependencyTelemetry()
            {
                Name = "https://bing.com", Context = { InstrumentationKey = config.InstrumentationKey }
            });

            // ASSERT
            Assert.AreEqual(2, simpleTelemetryProcessorSpy.ReceivedCalls);
            Assert.AreEqual("http://microsoft.ru", (simpleTelemetryProcessorSpy.ReceivedItems[0] as DependencyTelemetry).Name);
            Assert.AreEqual("https://bing.com", (simpleTelemetryProcessorSpy.ReceivedItems[1] as DependencyTelemetry).Name);
            Assert.AreEqual(2, accumulatorManager.CurrentDataAccumulator.AIDependencyCallCount);
        }
        public void QuickPulseTelemetryProcessorCallsNext()
        {
            // ARRANGE
            var spy = new SimpleTelemetryProcessorSpy();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(spy);

            // ACT
            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(1, spy.ReceivedCalls);
        }
        public void QuickPulseTelemetryProcessorIgnoresUnrelatedTelemetryItems()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            telemetryProcessor.Process(new EventTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new MetricTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new PageViewTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new PerformanceCounterTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new SessionStateTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new TraceTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(0, accumulatorManager.CurrentDataAccumulator.AIRequestCount);
            Assert.AreEqual(0, accumulatorManager.CurrentDataAccumulator.AIDependencyCallCount);
        }
        public void QuickPulseTelemetryProcessorHandlesMultipleThreadsCorrectly()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // expected data loss if threading is misimplemented is around 10% (established through experiment)
            int taskCount = 10000;
            var tasks     = new List <Task>(taskCount);

            for (int i = 0; i < taskCount; i++)
            {
                var requestTelemetry = new RequestTelemetry()
                {
                    ResponseCode = (i % 2 == 0) ? "200" : "500",
                    Duration     = TimeSpan.FromMilliseconds(i),
                    Context      = { InstrumentationKey = "some ikey" }
                };

                var task = new Task(() => telemetryProcessor.Process(requestTelemetry));
                tasks.Add(task);
            }

            // ACT
            tasks.ForEach(task => task.Start());

            Task.WaitAll(tasks.ToArray());

            // ASSERT
            Assert.AreEqual(taskCount, accumulatorManager.CurrentDataAccumulator.AIRequestCount);
            Assert.AreEqual(taskCount / 2, accumulatorManager.CurrentDataAccumulator.AIRequestSuccessCount);
        }
        public void QuickPulseTelemetryModuleCollectsData()
        {
            if (QuickPulseTelemetryModuleTests.Ignored)
            {
                return;
            }

            // ARRANGE
            var pause    = TimeSpan.FromSeconds(1);
            var interval = TimeSpan.FromMilliseconds(1);
            var timings  = new QuickPulseTimings(interval, interval);
            var collectionTimeSlotManager = new QuickPulseCollectionTimeSlotManagerMock(timings);
            var filter1 = new[]
            {
                new FilterConjunctionGroupInfo()
                {
                    Filters = new[] { new FilterInfo()
                                      {
                                          FieldName = "Name", Predicate = Predicate.Equal, Comparand = "Request1"
                                      } }
                }
            };
            var metrics = new[]
            {
                new CalculatedMetricInfo()
                {
                    Id            = "Metric0",
                    TelemetryType = TelemetryType.Request,
                    Projection    = "Id",
                    Aggregation   = AggregationType.Avg,
                    FilterGroups  = filter1
                }
            };
            var serviceClient = new QuickPulseServiceClientMock {
                ReturnValueFromPing = true, ReturnValueFromSubmitSample = true
            };

            serviceClient.CollectionConfigurationInfo = new CollectionConfigurationInfo()
            {
                ETag = "1", Metrics = metrics
            };
            var performanceCollector = new PerformanceCollectorMock();
            var topCpuCollector      = new QuickPulseTopCpuCollectorMock()
            {
                TopProcesses = new List <Tuple <string, int> >()
                {
                    Tuple.Create("Process1", 25)
                }
            };

            var module             = new QuickPulseTelemetryModule(collectionTimeSlotManager, null, serviceClient, performanceCollector, topCpuCollector, timings);
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            telemetryProcessor.Initialize(new TelemetryConfiguration());
            module.RegisterTelemetryProcessor(telemetryProcessor);

            // ACT
            var telemetryConfiguration = new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            };

            module.Initialize(telemetryConfiguration);

            Thread.Sleep(pause);

            telemetryProcessor.Process(new RequestTelemetry()
            {
                Id = "1", Name = "Request1", Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            Thread.Sleep(pause);

            Assert.AreEqual(1, serviceClient.PingCount);

            // ASSERT
            serviceClient.ReturnValueFromPing         = false;
            serviceClient.ReturnValueFromSubmitSample = false;

            Thread.Sleep(pause);
            Assert.IsTrue(serviceClient.SnappedSamples.Count > 0);

            Assert.IsTrue(serviceClient.SnappedSamples.Any(s => s.AIRequestsPerSecond > 0));
            Assert.IsTrue(serviceClient.SnappedSamples.Any(s => s.AIDependencyCallsPerSecond > 0));
            Assert.IsTrue(
                serviceClient.SnappedSamples.Any(s => Math.Abs(s.PerfCountersLookup[@"\Processor(_Total)\% Processor Time"]) > double.Epsilon));

            Assert.IsTrue(
                serviceClient.SnappedSamples.TrueForAll(s => s.TopCpuData.Single().Item1 == "Process1" && s.TopCpuData.Single().Item2 == 25));

            Assert.IsTrue(
                serviceClient.SnappedSamples.Any(
                    s =>
                    s.CollectionConfigurationAccumulator.MetricAccumulators.Any(
                        a => a.Value.MetricId == "Metric0" && a.Value.CalculateAggregation(out long count) == 1.0d && count == 1)));
        }
        public void CollectionConfigurationCarriesOverQuotaWhenCreatingDocumentStreams()
        {
            // ARRANGE
            var timeProvider = new ClockMock();

            CollectionConfigurationError[] errors;
            var oldDocumentStreamInfos = new[]
            {
                new DocumentStreamInfo()
                {
                    Id = "Stream1",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Request,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream2",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Dependency,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream3",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Exception,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                }
            };

            var newDocumentStreamInfos = new[]
            {
                new DocumentStreamInfo()
                {
                    Id = "Stream1",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Request,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream2",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Dependency,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream3",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Exception,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream4",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Event,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                },
                new DocumentStreamInfo()
                {
                    Id = "Stream5",
                    DocumentFilterGroups =
                        new[]
                    {
                        new DocumentFilterConjunctionGroupInfo()
                        {
                            TelemetryType = TelemetryType.Trace,
                            Filters       = new FilterConjunctionGroupInfo()
                            {
                                Filters = new FilterInfo[0]
                            }
                        }
                    }
                }
            };

            var oldCollectionConfigurationInfo = new CollectionConfigurationInfo()
            {
                DocumentStreams = oldDocumentStreamInfos, ETag = "ETag1"
            };
            var oldCollectionConfiguration = new CollectionConfiguration(oldCollectionConfigurationInfo, out errors, timeProvider);

            // spend some quota on the old configuration
            var accumulatorManager = new QuickPulseDataAccumulatorManager(oldCollectionConfiguration);
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            // the initial quota is 3
            telemetryProcessor.Process(new RequestTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new DependencyTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(new ExceptionTelemetry()
            {
                Context = { InstrumentationKey = "some ikey" }
            });

            // ACT
            // the new configuration must carry the quotas over from the old one (only for those document streams that already existed)
            var newCollectionConfigurationInfo = new CollectionConfigurationInfo()
            {
                DocumentStreams = newDocumentStreamInfos, ETag = "ETag1"
            };
            var newCollectionConfiguration = new CollectionConfiguration(
                newCollectionConfigurationInfo,
                out errors,
                timeProvider,
                oldCollectionConfiguration.DocumentStreams);

            // ASSERT
            DocumentStream[] documentStreams = newCollectionConfiguration.DocumentStreams.ToArray();
            Assert.AreEqual(5, documentStreams.Length);

            Assert.AreEqual("Stream1", documentStreams[0].Id);
            Assert.AreEqual(2, documentStreams[0].RequestQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[0].DependencyQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[0].ExceptionQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[0].EventQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[0].EventQuotaTracker.CurrentQuota);

            Assert.AreEqual("Stream2", documentStreams[1].Id);
            Assert.AreEqual(3, documentStreams[1].RequestQuotaTracker.CurrentQuota);
            Assert.AreEqual(1, documentStreams[1].DependencyQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[1].ExceptionQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[1].EventQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[1].EventQuotaTracker.CurrentQuota);

            Assert.AreEqual("Stream3", documentStreams[2].Id);
            Assert.AreEqual(3, documentStreams[2].RequestQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[2].DependencyQuotaTracker.CurrentQuota);
            Assert.AreEqual(0, documentStreams[2].ExceptionQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[2].EventQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[2].EventQuotaTracker.CurrentQuota);

            Assert.AreEqual("Stream4", documentStreams[3].Id);
            Assert.AreEqual(3, documentStreams[3].RequestQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[3].DependencyQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[3].ExceptionQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[3].EventQuotaTracker.CurrentQuota);
            Assert.AreEqual(3, documentStreams[3].EventQuotaTracker.CurrentQuota);
        }
Beispiel #13
0
 void ITelemetryProcessor.Process(ITelemetry item)
 {
     base.Process(item);
     _appWideQuickPulseTelemetryProcessor.Process(item);
 }
        public void QuickPulseTelemetryProcessorKeepsAccurateCountOfRequests()
        {
            // ARRANGE
            var accumulatorManager = new QuickPulseDataAccumulatorManager();
            var telemetryProcessor = new QuickPulseTelemetryProcessor(new SimpleTelemetryProcessorSpy());

            ((IQuickPulseTelemetryProcessor)telemetryProcessor).StartCollection(
                accumulatorManager,
                new Uri("http://microsoft.com"),
                new TelemetryConfiguration()
            {
                InstrumentationKey = "some ikey"
            });

            // ACT
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = false,
                ResponseCode = "200",
                Duration     = TimeSpan.FromSeconds(1),
                Context      = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = true,
                ResponseCode = "200",
                Duration     = TimeSpan.FromSeconds(2),
                Context      = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = false,
                ResponseCode = string.Empty,
                Duration     = TimeSpan.FromSeconds(3),
                Context      = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = null,
                ResponseCode = string.Empty,
                Duration     = TimeSpan.FromSeconds(4),
                Context      = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = true,
                ResponseCode = string.Empty,
                Duration     = TimeSpan.FromSeconds(5),
                Context      = { InstrumentationKey = "some ikey" }
            });
            telemetryProcessor.Process(
                new RequestTelemetry()
            {
                Success      = null,
                ResponseCode = "404",
                Duration     = TimeSpan.FromSeconds(6),
                Context      = { InstrumentationKey = "some ikey" }
            });

            // ASSERT
            Assert.AreEqual(6, accumulatorManager.CurrentDataAccumulator.AIRequestCount);
            Assert.AreEqual(
                1 + 2 + 3 + 4 + 5 + 6,
                TimeSpan.FromTicks(accumulatorManager.CurrentDataAccumulator.AIRequestDurationInTicks).TotalSeconds);
            Assert.AreEqual(4, accumulatorManager.CurrentDataAccumulator.AIRequestSuccessCount);
            Assert.AreEqual(2, accumulatorManager.CurrentDataAccumulator.AIRequestFailureCount);
        }