Skip to content

Commit 3589956

Browse files
Scope ActivityListener in test to not interfere with other tests (#36908)
1 parent e3c86b7 commit 3589956

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Hosting/Hosting/test/HostingApplicationDiagnosticsTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,12 @@ public void ActivityOnImportHookIsCalled()
496496
[Fact]
497497
public void ActivityListenersAreCalled()
498498
{
499-
var hostingApplication = CreateApplication(out var features);
499+
var testSource = new ActivitySource(Path.GetRandomFileName());
500+
var hostingApplication = CreateApplication(out var features, activitySource: testSource);
500501
var parentSpanId = "";
501502
using var listener = new ActivityListener
502503
{
503-
ShouldListenTo = activitySource => true,
504+
ShouldListenTo = activitySource => ReferenceEquals(activitySource, testSource),
504505
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData,
505506
ActivityStarted = activity =>
506507
{

0 commit comments

Comments
 (0)