-
Notifications
You must be signed in to change notification settings - Fork 66
Change how EndSegment is called for Tasks #197
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
Conversation
Thank you for contributing to the .NET Agent! A member of our team will be around to take a look shortly and kick off a build. |
Should this PR also revert this code? Lines 41 to 49 in 03d6ca8
|
If the Task has already completed, we call EndSegment (synchronously) immediately. Otherwise, we always continue with TaskContinuationOptions.ExecuteSynchronously, which runs our continuation as soon as possible (on the thread that completed the task). This avoids task continuations being delayed until much later in the ASP.NET pipeline (due to when AspNetSynchronizationContext posts them), which causes inaccurate timings.
9c621a2
to
00d496d
Compare
That's a good question. I think that I still have the test app that I used to verify that fix so I can include that in the additional timing tests we want to do to try to confirm that some previously problematic scenarios are still working as expected. Unfortunately, we haven't come up with a good way to automate these types of timing tests yet. |
I'm still working my way through testing the timing of some of our previously problematic async scenarios, but I was able to test that the Redis instrumentation, with the changes in this PR, can go back to using |
ci test this please |
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.
The timings for many of our async scenarios look good. Not only will this fix a few problems, but it helps pave the way forward for simplifying/standardizing our async timing. Great job identifying this!
This affects our DB timings in production, so I'm anxious to get this fix. However, I'd prefer to run the "official" NR Agent on our infrastructure rather than a version I built locally. Do you have a rough expectation of when this updated code might ship? (I'm not asking for a firm promise of a release date, but just want to understand when it's likely we'd be able to upgrade to this. I don't even know if you've shipped an agent built from this OSS code base yet, so I understand that things might take longer than expected.) |
We have a few things queued up for a release, and were waiting to kick off our release process until this was merged to better support your use case. We plan on possibly kicking off our release process tomorrow (9/16). This is definitely an area where we can improve our transparency, and can learn from other open source projects. |
We had a minor issue come up during our .NET 5 RC 1 validation that's delaying the release a little, but we still plan on running our release process soon. |
Description
If the
Task
has already completed, we callEndSegment
(synchronously) immediately. Otherwise, we always continue withTaskContinuationOptions.ExecuteSynchronously
on the defaultTaskScheduler
, which runs our continuation as soon as possible (on the thread that completed the task).This avoids task continuations being delayed until much later in the ASP.NET pipeline (due to when
AspNetSynchronizationContext
posts them), which causes inaccurate timings.Testing
Tested in prod as per #85 (comment).