Skip to content

Commit f7d1691

Browse files
committed
- rename RouteChange->Navigate
- don't propagate HTTP/SignalR links to event traces
1 parent 3e86bc0 commit f7d1691

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/Components/Components/src/ComponentsActivitySource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Components;
1212
internal class ComponentsActivitySource
1313
{
1414
internal const string Name = "Microsoft.AspNetCore.Components";
15-
internal const string OnRouteName = $"{Name}.RouteChange";
15+
internal const string OnRouteName = $"{Name}.Navigate";
1616
internal const string OnEventName = $"{Name}.HandleEvent";
1717

1818
private static ActivitySource ActivitySource { get; } = new ActivitySource(Name);

src/Components/Server/src/Circuits/CircuitActivitySource.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.AspNetCore.Components.Server.Circuits;
99
internal class CircuitActivitySource
1010
{
1111
internal const string Name = "Microsoft.AspNetCore.Components.Server.Circuits";
12-
internal const string OnCircuitName = $"{Name}.CircuitStart";
12+
internal const string OnCircuitName = $"{Name}.StartCircuit";
1313

1414
private ComponentsActivityLinkStore? _activityLinkStore;
1515

@@ -42,20 +42,22 @@ public CircuitActivityHandle StartCircuitActivity(string circuitId, ActivityCont
4242
}
4343
if (httpActivityContext != default)
4444
{
45-
// store the http link
46-
_activityLinkStore.SetActivityContext(ComponentsActivityLinkStore.Http, httpActivityContext, null);
45+
// add the http link
46+
activity.AddLink(new ActivityLink(httpActivityContext));
4747
}
4848
if (signalRActivity != null && signalRActivity.Source.Name == "Microsoft.AspNetCore.SignalR.Server")
4949
{
50-
// store the SignalR link
51-
_activityLinkStore.SetActivityContext(ComponentsActivityLinkStore.SignalR, signalRActivity.Context, null);
50+
// add the SignalR link
51+
activity.AddLink(new ActivityLink(signalRActivity.Context));
5252
}
5353
}
5454
return new CircuitActivityHandle { Previous = signalRActivity, Activity = activity };
5555
}
5656
return default;
5757
}
5858

59+
// We call this at the end of circuit creation, rather than at the end of the circuit lifecycle
60+
// because long-lived traces are difficult to work with in the telemetry UIs
5961
public void StopCircuitActivity(CircuitActivityHandle activityHandle, Exception? ex)
6062
{
6163
var activity = activityHandle.Activity;

src/Components/Server/test/Circuits/CircuitActivitySourceTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ public void StartCircuitActivity_CreatesAndStartsActivity()
5454
Assert.Equal(ActivityKind.Internal, activity.Kind);
5555
Assert.True(activity.IsAllDataRequested);
5656
Assert.Equal(circuitId, activity.GetTagItem("aspnetcore.components.circuit.id"));
57-
Assert.Empty(activity.Links);
57+
Assert.Contains(activity.Links, link => link.Context == httpContext);
5858
Assert.False(activity.IsStopped);
5959

6060
circuitActivitySource.StopCircuitActivity(activityHandle, null);
6161
Assert.True(activity.IsStopped);
62-
Assert.Contains(activity.Links, link => link.Context == httpContext);
6362
}
6463

6564
[Fact]

0 commit comments

Comments
 (0)