diff --git a/sdk/core/Azure.Core/tests/TestFramework/ClientDiagnosticListener.cs b/sdk/core/Azure.Core/tests/TestFramework/ClientDiagnosticListener.cs index 4574815ac99de..b0b78e1ad0665 100644 --- a/sdk/core/Azure.Core/tests/TestFramework/ClientDiagnosticListener.cs +++ b/sdk/core/Azure.Core/tests/TestFramework/ClientDiagnosticListener.cs @@ -58,7 +58,7 @@ public void OnNext(KeyValuePair value) var name = value.Key.Substring(0, value.Key.Length - stopSuffix.Length); foreach (ProducedDiagnosticScope producedDiagnosticScope in Scopes) { - if (producedDiagnosticScope.Name == name) + if (producedDiagnosticScope.Activity.Id == Activity.Current.Id) { producedDiagnosticScope.IsCompleted = true; return; diff --git a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Diagnostics/DiagnosticsTests.cs b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Diagnostics/DiagnosticsTests.cs index 299a69afb1a8e..776f879420bf0 100755 --- a/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Diagnostics/DiagnosticsTests.cs +++ b/sdk/eventhub/Azure.Messaging.EventHubs.Processor/tests/Diagnostics/DiagnosticsTests.cs @@ -73,7 +73,6 @@ public async Task UpdateCheckpointAsyncCreatesScope() /// /// [Test] - [Ignore("Diagnostic scope is not completing properly. Maybe the listener is being disposed of first.")] public async Task RunPartitionProcessingAsyncCreatesScopeForEventProcessing() { var mockStorage = new MockCheckPointStorage(); @@ -149,12 +148,10 @@ async IAsyncEnumerable mockPartitionEventEnumerable() // Validate diagnostics functionality. - ClientDiagnosticListener.ProducedDiagnosticScope scope = listener.Scopes.Single(); - - Assert.That(scope.Name, Is.EqualTo(DiagnosticProperty.EventProcessorProcessingActivityName)); - Assert.That(scope.Links, Has.One.EqualTo("id")); - Assert.That(scope.Links, Has.One.EqualTo("id2")); - Assert.That(scope.Activity.Tags, Has.One.EqualTo(new KeyValuePair(DiagnosticProperty.KindAttribute, DiagnosticProperty.ServerKind)), "The activities tag should be server."); + Assert.That(listener.Scopes.Select(s => s.Name), Has.All.EqualTo(DiagnosticProperty.EventProcessorProcessingActivityName)); + Assert.That(listener.Scopes.SelectMany(s => s.Links), Has.One.EqualTo("id")); + Assert.That(listener.Scopes.SelectMany(s => s.Links), Has.One.EqualTo("id2")); + Assert.That(listener.Scopes.SelectMany(s => s.Activity.Tags), Has.Exactly(2).EqualTo(new KeyValuePair(DiagnosticProperty.KindAttribute, DiagnosticProperty.ServerKind)), "The activities tag should be server."); } private class MockConnection : EventHubConnection