-
Notifications
You must be signed in to change notification settings - Fork 773
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
Remove ActivitySourceAdapter from AspNetCore #1654
Remove ActivitySourceAdapter from AspNetCore #1654
Conversation
@@ -81,36 +79,37 @@ public override void OnStartActivity(Activity activity, object payload) | |||
return; | |||
} | |||
|
|||
ActivityContext activityContext = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to parentActivityContextOfOriginalActivity
if you don't mind looong names.
Not for merging now. Just to demonstrate the concept. We can borrow this approach for other instrumentation and see if it can a good alternative, than exposing |
|
@@ -208,8 +207,6 @@ public override void OnStopActivity(Activity activity, object payload) | |||
// the one created by the instrumentation. | |||
// And retrieve it here, and set it to Current. | |||
} | |||
|
|||
this.activitySource.Stop(activity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like AspNetCore hosting keeps a reference to the Activity it started and that's the one it will stop:
So my question is: Does the Activity we create in this approach actually get stopped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CodeBlanch , when you say "this approach", that means the old approach or this new one? For the new one, we are replacing the activity, but, if aspnetcore has a reference there, we might be creating a new one that would never be stopped.
@cijothomas to comment as well :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddynaka I meant the new approach sorry 😄
For the new one, we are replacing the activity, but, if aspnetcore has a reference there, we might be creating a new one that would never be stopped.
Ya, exactly. That would be a problem!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are stopping our own activity. aspnet core stops their activity. check line 197 for our activity being stopped.
(This is a diff. issue in AspNet, as it relies on Activity.Current, so we need to restore it for AspNet, but for AspNetCore we dont. But agree - this is a bit flaky design, and will fall apart if aspnetcore changes their implementation. We'll need to revisit this in .NET6, when they are expected to do some changes.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eddynaka Can you verify the one we're creating is stopped correctly? I see the activity.Stop
on LN197 but we're stopping the same activity passed in OnStopActivity so it should already be stopped? 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OnStopActivity gets Activity.Current, which should be the one we created, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya you're right it works fine. Just took it for a spin to verify.
This is already known. Even if .NET libraries (or any library) move to ActivitySource, it'll only be for new version only. For older version, use the approach demo-ed in this PR. After 1.0.0 is out, we'll revisit ActivitySourceAdapter approach. |
Closing as this PR was meant to demo an concept only. |
Refs #1585
Changes
Please provide a brief description of the changes here.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes