Skip to content

Commit

Permalink
Make completion of diagnostic scope more deterministic (#9316)
Browse files Browse the repository at this point in the history
  • Loading branch information
christothes authored and pakrym committed Jan 8, 2020
1 parent 603f38e commit 6487781
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void OnNext(KeyValuePair<string, object> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public async Task UpdateCheckpointAsyncCreatesScope()
/// </summary>
///
[Test]
[Ignore("Diagnostic scope is not completing properly. Maybe the listener is being disposed of first.")]
public async Task RunPartitionProcessingAsyncCreatesScopeForEventProcessing()
{
var mockStorage = new MockCheckPointStorage();
Expand Down Expand Up @@ -149,12 +148,10 @@ async IAsyncEnumerable<PartitionEvent> 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<string, string>(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<string, string>(DiagnosticProperty.KindAttribute, DiagnosticProperty.ServerKind)), "The activities tag should be server.");
}

private class MockConnection : EventHubConnection
Expand Down

0 comments on commit 6487781

Please sign in to comment.