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

Update HttpInListener to add gRPC tags - By creating a new activity with the OperationName used by the framework #1879

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
db21758
Update HttpInListener to add gRPC tags
utpilla Mar 8, 2021
6a679cf
Update ASP.NET Core instrumnetation to use the OperationName used by …
utpilla Mar 8, 2021
84e61b1
Merge remote-tracking branch 'origin/main' into utpilla/Fix-gRPC-Inst…
utpilla Mar 8, 2021
2b0271f
Address PR comments
utpilla Mar 8, 2021
de2d299
Merged with origin/main
utpilla Mar 9, 2021
8f026fc
Correct merge with origin/main
utpilla Mar 10, 2021
bcc6ea8
Merge remote-tracking branch 'fork/utpilla/Fix-gRPC-Instrumentation-F…
utpilla Mar 10, 2021
8b32725
Fix merge error
utpilla Mar 10, 2021
aef69cd
Merge remote-tracking branch 'origin/main' into utpilla/Fix-gRPC-Inst…
utpilla Mar 10, 2021
b5765c4
Merge branch 'main' into utpilla/Fix-gRPC-Instrumentation-For-Sibling…
utpilla Mar 18, 2021
aabfc8d
Resolve merge conflict
utpilla Mar 19, 2021
a53199f
Merge remote-tracking branch 'fork/utpilla/Fix-gRPC-Instrumentation-F…
utpilla Mar 19, 2021
91e52c6
Fix formatting
utpilla Mar 19, 2021
642842e
Merge branch 'main' into utpilla/Fix-gRPC-Instrumentation-For-Sibling…
utpilla Apr 12, 2021
a1b58d1
Merge with origin/main
utpilla Apr 26, 2021
214c4f9
Merge branch 'utpilla/Fix-gRPC-Instrumentation-For-Sibling-Activity-U…
utpilla Apr 26, 2021
b872349
Use tag instead of custom property in the HttpListener; Added CheckFi…
utpilla Apr 27, 2021
6e5da33
Set tag value as True instead of boolean true
utpilla Apr 27, 2021
3a068ea
Use bool.TrueString instead of True
utpilla Apr 27, 2021
a03f7d1
Merge branch 'main' into utpilla/Fix-gRPC-Instrumentation-For-Sibling…
cijothomas May 3, 2021
963f930
Merge remote-tracking branch 'origin/main' into utpilla/Fix-gRPC-Inst…
utpilla May 3, 2021
12222e4
Address PR comments
utpilla May 3, 2021
39f60a4
Trigger CI Run
utpilla May 3, 2021
44383ad
Merge remote-tracking branch 'origin/main' into utpilla/Fix-gRPC-Inst…
utpilla May 3, 2021
33fd687
Merge branch 'main' into utpilla/Fix-gRPC-Instrumentation-For-Sibling…
cijothomas May 3, 2021
6405fbd
Update CHANGELOG.md
utpilla May 3, 2021
58a062d
Merge branch 'utpilla/Fix-gRPC-Instrumentation-For-Sibling-Activity-U…
utpilla May 3, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public override void OnStartActivity(Activity activity, object payload)
// Starting the new activity make it the Activity.Current one.
newOne.Start();

newOne.SetTag("IsCreatedByInstrumentation", true);
newOne.SetTag("IsCreatedByInstrumentation", "True");
utpilla marked this conversation as resolved.
Show resolved Hide resolved

// Set IsAllDataRequested to false for the activity created by the framework to only export the sibling activity and not the framework activity
activity.IsAllDataRequested = false;
Expand Down Expand Up @@ -215,7 +215,7 @@ public override void OnStopActivity(Activity activity, object payload)
}
}

if (activity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is bool isCreatedByInstrumentation && isCreatedByInstrumentation)
if (activity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is "True")
{
// If instrumentation started a new Activity, it must
// be stopped here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ public async Task SuccessfulTemplateControllerCallUsesParentContext()
// List of invocations
// 1. SetParentProvider for TracerProviderSdk
// 2. OnStart for the activity created by AspNetCore with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn
// 3. OnStart for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, true)
// 4. OnEnd for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, true)
// 3. OnStart for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, "True")
// 4. OnEnd for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, "True")

// we should only call Processor.OnEnd once for the sibling activity
Assert.Single(activityProcessor.Invocations, invo => invo.Method.Name == "OnEnd");
Expand All @@ -191,7 +191,7 @@ public async Task SuccessfulTemplateControllerCallUsesParentContext()
#else
// ASP.NET Core before 3.x is not W3C aware and hence Activity created by it
// is always ignored and new one is created by the Instrumentation
Assert.True(activity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is bool isCreatedByInstrumentation && isCreatedByInstrumentation);
Assert.True(activity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is "True");
#endif
Assert.Equal("api/Values/{id}", activity.DisplayName);

Expand Down Expand Up @@ -242,8 +242,8 @@ public async Task CustomPropagator()
// List of invocations on the processor
// 1. SetParentProvider for TracerProviderSdk
// 2. OnStart for the activity created by AspNetCore with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn
// 3. OnStart for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, true)
// 4. OnEnd for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, true)
// 3. OnStart for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, "True")
// 4. OnEnd for the sibling activity created by the instrumentation library with the OperationName: Microsoft.AspNetCore.Hosting.HttpRequestIn and the first tag that is added is (IsCreatedByInstrumentation, "True")
Assert.Equal(4, activityProcessor.Invocations.Count);

var startedActivities = activityProcessor.Invocations.Where(invo => invo.Method.Name == "OnStart");
Expand All @@ -261,14 +261,14 @@ public async Task CustomPropagator()
Assert.Single(startedActivities, item =>
{
var startedActivity = item.Arguments[0] as Activity;
return startedActivity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is bool isCreatedByInstrumentation && isCreatedByInstrumentation;
return startedActivity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is "True";
});

// Only the sibling activity is sent to Processor.OnEnd
Assert.Single(stoppedActivities, item =>
{
var stoppedActivity = item.Arguments[0] as Activity;
return stoppedActivity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is bool isCreatedByInstrumentation && isCreatedByInstrumentation;
return stoppedActivity.CheckFirstTag("IsCreatedByInstrumentation", out var tagValue) && tagValue is "True";
});

var activity = activityProcessor.Invocations.FirstOrDefault(invo => invo.Method.Name == "OnEnd").Arguments[0] as Activity;
Expand Down