Skip to content

Commit

Permalink
When Activity is lost, copy parent tags to the new Activity (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liudmila Molkova authored Aug 27, 2018
1 parent fd19e41 commit 675f794
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Microsoft.AspNet.TelemetryCorrelation/ActivityHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ private static Activity RestoreActivity(Activity root)
childActivity.AddBaggage(item.Key, item.Value);
}

foreach (var item in root.Tags)
{
childActivity.AddTag(item.Key, item.Value);
}

childActivity.Start();

AspNetTelemetryCorrelationEventSource.Log.ActivityRestored(childActivity.Id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public void Dispose()
public async Task Can_Restore_Activity()
{
var rootActivity = CreateActivity();

rootActivity.AddTag("k1", "v1");
rootActivity.AddTag("k2", "v2");
var context = HttpContextHelper.GetFakeHttpContext();
await Task.Run(() =>
{
Expand Down Expand Up @@ -339,6 +342,10 @@ private void AssertIsRestoredActivity(Activity original, Activity restored)
var expectedBaggage = original.Baggage.OrderBy(item => item.Value);
var actualBaggage = restored.Baggage.OrderBy(item => item.Value);
Assert.Equal(expectedBaggage, actualBaggage);

var expectedTags = original.Tags.OrderBy(item => item.Value);
var actualTags = restored.Tags.OrderBy(item => item.Value);
Assert.Equal(expectedTags, actualTags);
}

private Activity CreateActivity()
Expand Down

0 comments on commit 675f794

Please sign in to comment.