public void TimestampAddNanos_Negative() { ITimestamp timestamp = Timestamp.Create(1234, 223); Assert.Equal(Timestamp.Create(1234, 0), timestamp.AddNanos(-223)); Assert.Equal(Timestamp.Create(1233, 0), timestamp.AddNanos(-1000000223)); Assert.Equal(Timestamp.Create(1232, 699799723), timestamp.AddNanos(-1300200500)); Assert.Equal(Timestamp.Create(1229, 876544010), timestamp.AddNanos(-4123456213L)); Assert.Equal(Timestamp.Create(1234L - 9223372036L - 1, 223 + 145224192), timestamp.AddNanos(long.MinValue)) ; }
public void TimestampAddNanos() { ITimestamp timestamp = Timestamp.Create(1234, 223); Assert.Equal(timestamp, timestamp.AddNanos(0)); Assert.Equal(Timestamp.Create(1235, 0), timestamp.AddNanos(999999777)); Assert.Equal(Timestamp.Create(1235, 300200723), timestamp.AddNanos(1300200500)); Assert.Equal(Timestamp.Create(1236, 0), timestamp.AddNanos(1999999777)); Assert.Equal(Timestamp.Create(1243, 876544012), timestamp.AddNanos(9876543789L)); Assert.Equal(Timestamp.Create(1234L + 9223372036L, 223 + 854775807), timestamp.AddNanos(long.MaxValue)) ; }
public ITimestamp ConvertNanoTime(long nanoTime) { return(timestamp.AddNanos(nanoTime - this.nanoTime)); }
public void ToSpanData_ActiveSpan() { ISpan span = Span.StartSpan( spanContext, recordSpanOptions, SPAN_NAME, parentSpanId, true, TraceParams.DEFAULT, startEndHandler, timestampConverter, testClock); span.PutAttribute( "MySingleStringAttributeKey", AttributeValue.StringAttributeValue("MySingleStringAttributeValue")); span.PutAttributes(attributes); testClock.AdvanceTime(Duration.Create(0, 100)); span.AddAnnotation(Annotation.FromDescription(ANNOTATION_DESCRIPTION)); testClock.AdvanceTime(Duration.Create(0, 100)); span.AddAnnotation(ANNOTATION_DESCRIPTION, attributes); testClock.AdvanceTime(Duration.Create(0, 100)); IMessageEvent networkEvent = MessageEvent.Builder(MessageEventType.RECEIVED, 1).SetUncompressedMessageSize(3).Build(); span.AddMessageEvent(networkEvent); testClock.AdvanceTime(Duration.Create(0, 100)); ILink link = Link.FromSpanContext(spanContext, LinkType.CHILD_LINKED_SPAN); span.AddLink(link); ISpanData spanData = ((Span)span).ToSpanData(); Assert.Equal(spanContext, spanData.Context); Assert.Equal(SPAN_NAME, spanData.Name); Assert.Equal(parentSpanId, spanData.ParentSpanId); Assert.True(spanData.HasRemoteParent); Assert.Equal(0, spanData.Attributes.DroppedAttributesCount); Assert.Equal(expectedAttributes, spanData.Attributes.AttributeMap); Assert.Equal(0, spanData.Annotations.DroppedEventsCount); Assert.Equal(2, spanData.Annotations.Events.Count); Assert.Equal(timestamp.AddNanos(100), spanData.Annotations.Events[0].Timestamp); Assert.Equal(Annotation.FromDescription(ANNOTATION_DESCRIPTION), spanData.Annotations.Events[0].Event); Assert.Equal(timestamp.AddNanos(200), spanData.Annotations.Events[1].Timestamp); Assert.Equal(Annotation.FromDescriptionAndAttributes(ANNOTATION_DESCRIPTION, attributes), spanData.Annotations.Events[1].Event); Assert.Equal(0, spanData.MessageEvents.DroppedEventsCount); Assert.Equal(1, spanData.MessageEvents.Events.Count); Assert.Equal(timestamp.AddNanos(300), spanData.MessageEvents.Events[0].Timestamp); Assert.Equal(networkEvent, spanData.MessageEvents.Events[0].Event); Assert.Equal(0, spanData.Links.DroppedLinksCount); Assert.Equal(1, spanData.Links.Links.Count); Assert.Equal(link, spanData.Links.Links[0]); Assert.Equal(timestamp, spanData.StartTimestamp); Assert.Null(spanData.Status); Assert.Null(spanData.EndTimestamp); var startEndMock = Mock.Get <IStartEndHandler>(startEndHandler); var spanBase = span as SpanBase; startEndMock.Verify(s => s.OnStart(spanBase), Times.Once); }