public MouseReferenceInfo(SpanData<ReferenceInfo>? spanData, SpanData<ReferenceInfo>? realSpanData, VirtualSnapshotPoint point) { SpanData = spanData; RealSpanData = realSpanData; virtualSpaces = point.VirtualSpaces; position = point.Position.Position; versionNumber = point.Position.Snapshot.Version.VersionNumber; }
internal bool GoTo(SpanData<ReferenceInfo>? spanData, bool newTab, bool followLocalRefs, bool canRecordHistory, bool canFollowReference, MoveCaretOptions options) { if (isDisposed) throw new ObjectDisposedException(nameof(IDocumentViewer)); return documentViewerControl.GoTo(spanData, newTab, followLocalRefs, canRecordHistory, canFollowReference, options); }
public void MoveCaretToSpan(SpanData<ReferenceInfo> refInfo, MoveCaretOptions options) { if (isDisposed) throw new ObjectDisposedException(nameof(IDocumentViewer)); documentViewerControl.MoveCaretToSpan(refInfo.Span, options); }
void UpdateReferenceHighlighting() { canHighlightReferences = textView.Options.IsReferenceHighlightingEnabled(); currentReference = GetCurrentReference(); RefreshAllTags(); }
public void BeforeEachTest() { SpanData = new SpanData("value"); }
private void when_asked_to_create_a_span() { var span = new SpanData(_value) .WithLabel(_label) .WithId(_id); var resultHtml = span.ToString(); _result = HTMLParser.Parse("<all>" + resultHtml + "</all>"); }
void DocumentViewer_GotNewContent(object sender, DocumentViewerGotNewContentEventArgs e) { spanReferenceCollection = documentViewer?.Content.GetCustomData <SpanDataCollection <ReferenceAndId> >(DocumentViewerContentDataIds.SpanReference) ?? SpanDataCollection <ReferenceAndId> .Empty; currentReference = GetCurrentReference(); currentSpanReference = GetCurrentSpanReference(); }
public override void OnEnd(SpanData span) { }
/// <summary> /// Translating <see cref="SpanData"/> to Stackdriver's Span /// According to <see href="https://cloud.google.com/trace/docs/reference/v2/rpc/google.devtools.cloudtrace.v2"/> specifications. /// </summary> /// <param name="spanData">Span in OpenTelemetry format.</param> /// <param name="projectId">Google Cloud Platform Project Id.</param> /// <returns><see cref="ISpan"/>.</returns> public static Google.Cloud.Trace.V2.Span ToSpan(this SpanData spanData, string projectId) { var spanId = spanData.Context.SpanId.ToHexString(); // Base span settings var span = new Google.Cloud.Trace.V2.Span { SpanName = new SpanName(projectId, spanData.Context.TraceId.ToHexString(), spanId), SpanId = spanId, DisplayName = new TruncatableString { Value = spanData.Name }, StartTime = spanData.StartTimestamp.ToTimestamp(), EndTime = spanData.EndTimestamp.ToTimestamp(), ChildSpanCount = null, }; if (spanData.ParentSpanId != null) { var parentSpanId = spanData.ParentSpanId.ToHexString(); if (!string.IsNullOrEmpty(parentSpanId)) { span.ParentSpanId = parentSpanId; } } // Span Links if (spanData.Links != null) { span.Links = new Google.Cloud.Trace.V2.Span.Types.Links { Link = { spanData.Links.Select(l => l.ToLink()) }, }; } // Span Attributes if (spanData.Attributes != null) { span.Attributes = new Google.Cloud.Trace.V2.Span.Types.Attributes { AttributeMap = { spanData.Attributes?.ToDictionary( s => s.Key, s => s.Value?.ToAttributeValue()), }, }; } // StackDriver uses different labels that are used to categorize spans // replace attribute keys with StackDriver version foreach (var entry in httpLabelsToReplace) { if (span.Attributes.AttributeMap.TryGetValue(entry.Key, out var attrValue)) { span.Attributes.AttributeMap.Remove(entry.Key); span.Attributes.AttributeMap.Add(entry.Value, attrValue); } } return(span); }
private SpanData CreateTestSpan() { var startTimestamp = new DateTime(2019, 1, 1); var endTimestamp = startTimestamp.AddSeconds(60); var eventTimestamp = new DateTime(2019, 1, 1); var traceId = ActivityTraceId.CreateFromString("e8ea7e9ac72de94e91fabc613f9686b2".AsSpan()); var traceIdAsInt = new Int128(traceId); var spanId = ActivitySpanId.CreateFromString("6a69db47429ea340".AsSpan()); var spanIdAsInt = new Int128(spanId); var parentSpanId = ActivitySpanId.CreateFromBytes(new byte [] { 12, 23, 34, 45, 56, 67, 78, 89 }); var attributes = Attributes.Create(new Dictionary <string, object> { { "stringKey", "value" }, { "longKey", 1L }, { "longKey2", 1 }, { "doubleKey", 1D }, { "doubleKey2", 1F }, { "boolKey", true }, }, 0); var events = TimedEvents <IEvent> .Create(new List <ITimedEvent <IEvent> > { TimedEvent <IEvent> .Create( eventTimestamp, Event.Create( "Event1", new Dictionary <string, object> { { "key", "value" }, } ) ), TimedEvent <IEvent> .Create( eventTimestamp, Event.Create( "Event2", new Dictionary <string, object> { { "key", "value" }, } ) ), }, 0); var linkedSpanId = ActivitySpanId.CreateFromString("888915b6286b9c41".AsSpan()); var link = Link.FromSpanContext(SpanContext.Create( traceId, linkedSpanId, ActivityTraceFlags.Recorded, Tracestate.Empty)); var linkTraceIdAsInt = new Int128(link.Context.TraceId); var linkSpanIdAsInt = new Int128(link.Context.SpanId); var links = LinkList.Create(new List <ILink> { link }, 0); return(SpanData.Create( SpanContext.Create( traceId, spanId, ActivityTraceFlags.Recorded, Tracestate.Empty ), parentSpanId, Resource.Empty, "Name", startTimestamp, attributes, events, links, null, Status.Ok, SpanKind.Client, endTimestamp )); }
public override void OnStart(SpanData span) { }
public ReferencePosition(SpanData <ReferenceInfo> spanData) { this.SpanData = spanData; }
bool GoToCore(SpanData <ReferenceInfo> spanData, bool newTab, bool followLocalRefs, bool canRecordHistory, bool canJumpToReference) { Debug.Assert(spanData.Span.End <= wpfTextViewHost.TextView.TextSnapshot.Length); if (spanData.Span.End > wpfTextViewHost.TextView.TextSnapshot.Length) { return(false); } if (newTab) { Debug.Assert(canJumpToReference); if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); return(true); } if (followLocalRefs) { if (!IsOwnerOf(spanData)) { if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); return(true); } var localTarget = FindDefinition(spanData); if (localTarget != null) { spanData = localTarget.Value; } if (spanData.Data.IsDefinition) { if (canRecordHistory) { if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); } else { MoveCaretToSpan(spanData.Span); } return(true); } if (spanData.Data.IsLocal) { return(false); } if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); return(true); } else { var localTarget = FindDefinition(spanData); if (localTarget != null) { spanData = localTarget.Value; } int pos = -1; if (!spanData.Data.IsLocal) { if (spanData.Data.IsDefinition) { pos = spanData.Span.End; } } if (pos >= 0) { if (canRecordHistory) { if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); } else { textEditorHelper.SetFocus(); wpfTextViewHost.TextView.Selection.Clear(); wpfTextViewHost.TextView.Caret.MoveTo(new SnapshotPoint(wpfTextViewHost.TextView.TextSnapshot, pos)); wpfTextViewHost.TextView.Caret.EnsureVisible(); //TODO: Use wpfTextViewHost.TextView.ViewScroller.EnsureSpanVisible() } return(true); } if (spanData.Data.IsLocal) { return(false); // Allow another handler to set a new caret position } textEditorHelper.SetFocus(); if (!canJumpToReference) { return(false); } textEditorHelper.FollowReference(spanData.ToTextReference(), newTab); return(true); } }
bool GoToTarget(SpanData <ReferenceInfo>?spanData, bool canJumpToReference, bool canRecordHistory) => GoTo(spanData, false, true, canRecordHistory, canJumpToReference);
public override void OnEnd(SpanData span) { this.onEnd?.Invoke(span); exporter?.ExportAsync(new[] { span }, default); }
public void RecordSpan(SpanData span) { Spans.Add(span); }