public void NoEviction_Max()
        {
            var eq = new EvictingQueue <int>(4);

            Assert.Equal(0, eq.Count);
            Assert.Equal(0, eq.DroppedItems);

            eq.Add(0);
            Assert.Equal(1, eq.Count);
            Assert.Equal(0, eq.DroppedItems);
            eq.Add(1);
            Assert.Equal(2, eq.Count);
            Assert.Equal(0, eq.DroppedItems);
            eq.Add(2);
            Assert.Equal(3, eq.Count);
            Assert.Equal(0, eq.DroppedItems);
            eq.Add(3);
            Assert.Equal(4, eq.Count);
            Assert.Equal(0, eq.DroppedItems);

            var items = eq.ToArray();

            Assert.Equal(4, items.Length);
            Assert.Equal(0, items[0]);
            Assert.Equal(1, items[1]);
            Assert.Equal(2, items[2]);
            Assert.Equal(3, items[3]);
        }
            public void ConsiderForSampling(SpanBase span)
            {
                long spanEndNanoTime = span.EndNanoTime;

                if (span.Context.TraceOptions.IsSampled)
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndNanoTime - lastSampledNanoTime > TIME_BETWEEN_SAMPLES)
                    {
                        sampledSpansQueue.Add(span);
                        lastSampledNanoTime = spanEndNanoTime;
                    }
                }
                else
                {
                    // Need to compare by doing the subtraction all the time because in case of an overflow,
                    // this may never sample again (at least for the next ~200 years). No real chance to
                    // overflow two times because that means the process runs for ~200 years.
                    if (spanEndNanoTime - lastNotSampledNanoTime > TIME_BETWEEN_SAMPLES)
                    {
                        notSampledSpansQueue.Add(span);
                        lastNotSampledNanoTime = spanEndNanoTime;
                    }
                }
            }
Ejemplo n.º 3
0
 internal void AddEvent(T @event)
 {
     totalRecordedEvents++;
     events.Add(@event);
 }