コード例 #1
0
        internal override ISpanData ToSpanData()
        {
            if (!Options.HasFlag(SpanOptions.RECORD_EVENTS))
            {
                throw new InvalidOperationException("Getting SpanData for a Span without RECORD_EVENTS option.");
            }

            Attributes attributesSpanData = attributes == null?Attributes.Create(new Dictionary <string, IAttributeValue>(), 0)
                                                : Attributes.Create(attributes, attributes.NumberOfDroppedAttributes);

            ITimedEvents <IAnnotation>   annotationsSpanData   = CreateTimedEvents(InitializedAnnotations, timestampConverter);
            ITimedEvents <IMessageEvent> messageEventsSpanData = CreateTimedEvents(InitializedMessageEvents, timestampConverter);
            LinkList linksSpanData = links == null?LinkList.Create(new List <ILink>(), 0) : LinkList.Create(links.Events.ToList(), links.NumberOfDroppedEvents);

            return(SpanData.Create(
                       Context,
                       parentSpanId,
                       hasRemoteParent,
                       name,
                       timestampConverter.ConvertNanoTime(startNanoTime),
                       attributesSpanData,
                       annotationsSpanData,
                       messageEventsSpanData,
                       linksSpanData,
                       null, // Not supported yet.
                       hasBeenEnded ? StatusWithDefault : null,
                       hasBeenEnded ? timestampConverter.ConvertNanoTime(endNanoTime) : null));
        }
コード例 #2
0
        public void ConvertNanoTime()
        {
            mockClock.Setup(clock => clock.Now).Returns(timestamp);
            mockClock.Setup(clock => clock.NowNanos).Returns(1234L);

            ITimestampConverter timeConverter = TimestampConverter.Now(mockClock.Object);

            Assert.Equal(Timestamp.Create(1234, 10678), timeConverter.ConvertNanoTime(6234));
            Assert.Equal(Timestamp.Create(1234, 5444), timeConverter.ConvertNanoTime(1000));
            Assert.Equal(Timestamp.Create(1235, 0), timeConverter.ConvertNanoTime(999995556));
        }
コード例 #3
0
 internal ITimedEvent <T> ToSpanDataTimedEvent(ITimestampConverter timestampConverter)
 {
     return(TimedEvent <T> .Create(timestampConverter.ConvertNanoTime(this.nanoTime), this.@event));
 }