Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy parent tags to the new Activity when parent is lost #30

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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