11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using Aspire . Dashboard . Model ;
45using Aspire . Dashboard . Model . Otlp ;
56using Aspire . Dashboard . Otlp . Model ;
67using Aspire . Tests . Shared . Telemetry ;
@@ -25,7 +26,7 @@ public void Create_HasChildren_ChildrenPopulated()
2526 trace . AddSpan ( TelemetryTestHelpers . CreateOtlpSpan ( app2 , trace , scope , spanId : "1-1" , parentSpanId : "1" , startDate : new DateTime ( 2001 , 1 , 1 , 1 , 1 , 3 , DateTimeKind . Utc ) ) ) ;
2627
2728 // Act
28- var vm = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] ) ) ;
29+ var vm = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] , [ ] ) ) ;
2930
3031 // Assert
3132 Assert . Collection ( vm ,
@@ -41,6 +42,36 @@ public void Create_HasChildren_ChildrenPopulated()
4142 } ) ;
4243 }
4344
45+ [ Fact ]
46+ public void Create_OutgoingPeers_BrowserLink ( )
47+ {
48+ // Arrange
49+ var context = new OtlpContext { Logger = NullLogger . Instance , Options = new ( ) } ;
50+ var app1 = new OtlpApplication ( "app1" , "instance" , uninstrumentedPeer : false , context ) ;
51+ var app2 = new OtlpApplication ( "app2" , "instance" , uninstrumentedPeer : false , context ) ;
52+
53+ var trace = new OtlpTrace ( new byte [ ] { 1 , 2 , 3 } ) ;
54+ var scope = new OtlpScope ( TelemetryTestHelpers . CreateScope ( ) , context ) ;
55+ trace . AddSpan ( TelemetryTestHelpers . CreateOtlpSpan ( app1 , trace , scope , spanId : "1" , parentSpanId : null , startDate : new DateTime ( 2001 , 1 , 1 , 1 , 1 , 2 , DateTimeKind . Utc ) , kind : OtlpSpanKind . Client , attributes : [ KeyValuePair . Create ( "http.url" , "http://localhost:59267/6eed7c2dedc14419901b813e8fe87a86/getScriptTag" ) , KeyValuePair . Create ( "server.address" , "localhost" ) ] ) ) ;
56+ trace . AddSpan ( TelemetryTestHelpers . CreateOtlpSpan ( app2 , trace , scope , spanId : "2" , parentSpanId : null , startDate : new DateTime ( 2001 , 2 , 1 , 1 , 1 , 2 , DateTimeKind . Utc ) , kind : OtlpSpanKind . Client ) ) ;
57+
58+ // Act
59+ var vm = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ new BrowserLinkOutgoingPeerResolver ( ) ] , [ ] ) ) ;
60+
61+ // Assert
62+ Assert . Collection ( vm ,
63+ e =>
64+ {
65+ Assert . Equal ( "1" , e . Span . SpanId ) ;
66+ Assert . Equal ( "Browser Link" , e . UninstrumentedPeer ) ;
67+ } ,
68+ e =>
69+ {
70+ Assert . Equal ( "2" , e . Span . SpanId ) ;
71+ Assert . Null ( e . UninstrumentedPeer ) ;
72+ } ) ;
73+ }
74+
4475 [ Theory ]
4576 [ InlineData ( "1234" , true ) ] // Matches span ID
4677 [ InlineData ( "app1" , true ) ] // Matches application name
@@ -77,7 +108,7 @@ public void MatchesFilter_VariousCases_ReturnsExpected(string filter, bool expec
77108
78109 var vm = SpanWaterfallViewModel . Create (
79110 trace ,
80- new SpanWaterfallViewModel . TraceDetailState ( [ ] ) ) . First ( ) ;
111+ new SpanWaterfallViewModel . TraceDetailState ( [ ] , [ ] ) ) . First ( ) ;
81112
82113 // Act
83114 var result = vm . MatchesFilter ( filter , a => a . Application . ApplicationName , out _ ) ;
@@ -99,7 +130,7 @@ public void MatchesFilter_ParentSpanIncludedWhenChildMatched()
99130 trace . AddSpan ( parentSpan ) ;
100131 trace . AddSpan ( childSpan ) ;
101132
102- var vms = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] ) ) ;
133+ var vms = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] , [ ] ) ) ;
103134 var parent = vms [ 0 ] ;
104135 var child = vms [ 1 ] ;
105136
@@ -121,7 +152,7 @@ public void MatchesFilter_ChildSpanIncludedWhenParentMatched()
121152 trace . AddSpan ( parentSpan ) ;
122153 trace . AddSpan ( childSpan ) ;
123154
124- var vms = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] ) ) ;
155+ var vms = SpanWaterfallViewModel . Create ( trace , new SpanWaterfallViewModel . TraceDetailState ( [ ] , [ ] ) ) ;
125156 var parent = vms [ 0 ] ;
126157 var child = vms [ 1 ] ;
127158
0 commit comments