Пример #1
0
        /// <inheritdoc/>
        public void AddEvent(string name, IDictionary <string, object> eventAttributes)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (eventAttributes == null)
            {
                throw new ArgumentNullException(nameof(eventAttributes));
            }

            if (!this.IsRecordingEvents)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.HasEnded)
                {
                    // logger.log(Level.FINE, "Calling AddEvent() on an ended Span.");
                    return;
                }

                if (this.events == null)
                {
                    this.events =
                        new EvictingQueue <Event>(this.tracerConfiguration.MaxNumberOfEvents);
                }

                this.events.AddEvent(new Event(name, PreciseTimestamp.GetUtcNow(), eventAttributes));
            }
        }
Пример #2
0
        /// <inheritdoc/>
        public void AddLink(Link link)
        {
            if (link == null)
            {
                throw new ArgumentNullException(nameof(link));
            }

            if (!this.IsRecordingEvents)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.HasEnded)
                {
                    // logger.log(Level.FINE, "Calling addLink() on an ended Span.");
                    return;
                }

                if (this.links == null)
                {
                    this.links = new EvictingQueue <Link>(this.tracerConfiguration.MaxNumberOfLinks);
                }

                this.links.AddEvent(link);
            }
        }
Пример #3
0
        /// <inheritdoc/>
        public void AddEvent(Event addEvent)
        {
            if (addEvent == null)
            {
                throw new ArgumentNullException(nameof(addEvent));
            }

            if (!this.IsRecordingEvents)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.HasEnded)
                {
                    // logger.log(Level.FINE, "Calling AddEvent() on an ended Span.");
                    return;
                }

                if (this.events == null)
                {
                    this.events =
                        new EvictingQueue <Event>(this.tracerConfiguration.MaxNumberOfEvents);
                }

                this.events.AddEvent(addEvent);
            }
        }
Пример #4
0
        /// <inheritdoc/>
        public void AddEvent(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (!this.IsRecordingEvents)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.HasEnded)
                {
                    // logger.log(Level.FINE, "Calling AddEvent() on an ended Span.");
                    return;
                }

                if (this.events == null)
                {
                    this.events =
                        new EvictingQueue <IEvent>(this.traceConfig.MaxNumberOfEvents);
                }

                this.events.AddEvent(Event.Create(name, PreciseTimestamp.GetUtcNow()));
            }
        }
        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]);
        }
Пример #6
0
        /// <inheritdoc/>
        public void SetAttribute(KeyValuePair <string, object> keyValuePair)
        {
            if (keyValuePair.Key == null || keyValuePair.Value == null)
            {
                throw new ArgumentNullException(nameof(keyValuePair));
            }

            if (!this.IsRecordingEvents)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.HasEnded)
                {
                    // logger.log(Level.FINE, "Calling putAttributes() on an ended Span.");
                    return;
                }

                if (this.attributes == null)
                {
                    this.attributes = new EvictingQueue <KeyValuePair <string, object> >(this.tracerConfiguration.MaxNumberOfAttributes);
                }

                this.attributes.AddEvent(new KeyValuePair <string, object>(keyValuePair.Key, keyValuePair.Value));
            }
        }
        public void MaxItems0()
        {
            var eq = new EvictingQueue <int>(0)
            {
                0
            };

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

            Assert.Empty(eq);
        }
        public void NoReplacing()
        {
            var eq = new EvictingQueue <int>(1)
            {
                0
            };

            eq.Replace(1, 1);

            var items = eq.ToArray();

            Assert.Equal(0, items[0]);
        }
        public void NoEviction()
        {
            var eq = new EvictingQueue <int>(4)
            {
                0, 1, 2
            };

            var items = eq.ToArray();

            Assert.Equal(3, items.Length);
            Assert.Equal(0, items[0]);
            Assert.Equal(1, items[1]);
            Assert.Equal(2, items[2]);
        }
            public static void GetSamples(
                int maxSpansToReturn, List <SpanBase> output, EvictingQueue <SpanBase> queue)
            {
                SpanBase[] copy = queue.ToArray();

                foreach (SpanBase span in copy)
                {
                    if (output.Count >= maxSpansToReturn)
                    {
                        break;
                    }
                    output.Add(span);
                }
            }
            public static void GetSamples(
                int maxSpansToReturn, ICollection <SpanBase> output, EvictingQueue <SpanBase> queue)
            {
                var copy = queue.ToArray();

                foreach (var span in copy)
                {
                    if (output.Count >= maxSpansToReturn)
                    {
                        break;
                    }

                    output.Add(span);
                }
            }
        public void Eviction()
        {
            var eq = new EvictingQueue <int>(4)
            {
                0, 1, 2, 3, 4
            };

            Assert.Equal(4, eq.Count);
            Assert.Equal(1, eq.DroppedItems);

            var items = eq.ToArray();

            Assert.Equal(4, items.Length);
            Assert.Equal(1, items[0]);
            Assert.Equal(2, items[1]);
            Assert.Equal(3, items[2]);
            Assert.Equal(4, items[3]);
        }
 public static void GetSamplesFilteredByLatency(
     long latencyLowerNs,
     long latencyUpperNs,
     int maxSpansToReturn,
     List <SpanBase> output,
     EvictingQueue <SpanBase> queue)
 {
     SpanBase[] copy = queue.ToArray();
     foreach (SpanBase span in copy)
     {
         if (output.Count >= maxSpansToReturn)
         {
             break;
         }
         long spanLatencyNs = span.LatencyNs;
         if (spanLatencyNs >= latencyLowerNs && spanLatencyNs < latencyUpperNs)
         {
             output.Add(span);
         }
     }
 }
Пример #14
0
        /// <inheritdoc/>
        public void SetAttribute(KeyValuePair <string, object> keyValuePair)
        {
            if (keyValuePair.Key == null || keyValuePair.Value == null)
            {
                throw new ArgumentNullException(nameof(keyValuePair));
            }

            if (!this.IsRecordingEvents || this.hasEnded)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.attributes == null)
                {
                    this.attributes = new EvictingQueue <KeyValuePair <string, object> >(this.tracerConfiguration.MaxNumberOfAttributes);
                }

                this.attributes.AddEvent(new KeyValuePair <string, object>(keyValuePair.Key, keyValuePair.Value));
            }
        }
Пример #15
0
            public static void GetSamplesFilteredByLatency(
                TimeSpan latencyLower,
                TimeSpan latencyUpper,
                int maxSpansToReturn,
                ICollection <SpanBase> output,
                EvictingQueue <SpanBase> queue)
            {
                SpanBase[] copy = queue.ToArray();
                foreach (SpanBase span in copy)
                {
                    if (output.Count >= maxSpansToReturn)
                    {
                        break;
                    }

                    var spanLatency = span.Latency;
                    if (spanLatency >= latencyLower && spanLatency < latencyUpper)
                    {
                        output.Add(span);
                    }
                }
            }
Пример #16
0
        /// <inheritdoc/>
        public void AddEvent(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (!this.IsRecordingEvents || this.hasEnded)
            {
                return;
            }

            lock (this.@lock)
            {
                if (this.events == null)
                {
                    this.events =
                        new EvictingQueue <Event>(this.tracerConfiguration.MaxNumberOfEvents);
                }

                this.events.AddEvent(new Event(name, PreciseTimestamp.GetUtcNow()));
            }
        }
 public Bucket(int numSamples)
 {
     this.sampledSpansQueue    = new EvictingQueue <Span>(numSamples);
     this.notSampledSpansQueue = new EvictingQueue <Span>(numSamples);
 }
 public Bucket(int numSamples)
 {
     sampledSpansQueue    = new EvictingQueue <SpanBase>(numSamples);
     notSampledSpansQueue = new EvictingQueue <SpanBase>(numSamples);
 }
Пример #19
0
 public TraceEvents(int maxNumEvents)
 {
     events = new EvictingQueue <T>(maxNumEvents);
 }