Пример #1
0
        public void InstrumentationSamplingRateLimitsForTwoStage()
        {
            int numberOfTimesInstrumented = 0;
            var ins = new SimpleInstrumentor(new InstrumentationInfo()
            {
                Counters           = CounterTypes.StandardCounters,
                Description        = "test",
                InstanceName       = "Test instance",
                CategoryName       = "DOESNOTEXISTDONTLOOKFORIT",
                PublishCounters    = false,
                PublishEvent       = true,
                RaisePublishErrors = false
            })
            {
                PublishInstrumentationCallback = (a, b, c, d, e) => numberOfTimesInstrumented++
            };

            double samplingRate = 0.01;

            Enumerable.Range(0, 1000).ToList().ForEach(x =>
            {
                Correlation.SetId(Guid.NewGuid().ToString());
                ins.Finish(ins.Start(samplingRate));
            });

            Assert.InRange(numberOfTimesInstrumented, 1, 100);
        }
Пример #2
0
        public void InstrumentationSamplingRateLimitsForTwoStage()
        {
            int numberOfTimesInstrumented = 0;
            var ins = new SimpleInstrumentor(new InstrumentationInfo()
            {
                Description        = "test",
                InstanceName       = "Test instance",
                CategoryName       = "DOESNOTEXISTDONTLOOKFORIT",
                RaisePublishErrors = false
            });

            ins.Tracers.Add("a", new ActionTracer(() => numberOfTimesInstrumented++));

            double samplingRate = 0.01;

            Enumerable.Range(0, 1000).ToList().ForEach(x =>
            {
                Correlation.SetId(Guid.NewGuid().ToString());
                ins.Finish(ins.Start(samplingRate));
            });

            Assert.InRange(numberOfTimesInstrumented, 1, 100);
        }
Пример #3
0
        public void InstrumentationSamplingRateLimitsForTwoStage()
        {
            var numberOfTimesInstrumented = 0;
            var ins = new SimpleInstrumentor(new InstrumentationInfo
            {
                Counters           = CounterTypes.StandardCounters.ToArray(),
                Description        = "test",
                InstanceName       = "Test instance",
                CategoryName       = "DOESNOTEXISTDONTLOOKFORIT",
                PublishCounters    = true,
                PublishEvent       = true,
                RaisePublishErrors = false
            })
            {
                PublishInstrumentationCallback = (a, b, c, d) => numberOfTimesInstrumented++
            };

            const double samplingRate = 0.01d;

            Enumerable.Range(0, 1000).ToList().ForEach(x => ins.Finish(ins.Start(samplingRate)));

            Assert.InRange(numberOfTimesInstrumented, 1, 100);
        }