Restore Activity with OnExecuteRequestStep where available#24
Restore Activity with OnExecuteRequestStep where available#24
Conversation
| WriteEvent(7, id, name); | ||
| } | ||
|
|
||
| [Event(8, Message = "Activity started, Id='{0}'", Level = EventLevel.Informational)] |
There was a problem hiding this comment.
message doesn't match renamed method. started -> restored
| @@ -63,7 +63,7 @@ public static Activity RestoreCurrentActivity(Activity root) | |||
|
|
|||
| childActivity.Start(); | |||
There was a problem hiding this comment.
would it be better to start using that reflection trick here? We clearly need to start formulating feature requests for DiagnosticsSource wrt restoring Activities and custom activity management
| { | ||
| lock (sync) | ||
| { | ||
| if (!initialized) |
There was a problem hiding this comment.
You do not really need protection here. What's the harm initializing it twice?
There was a problem hiding this comment.
Init is called twice: Init special and Init regular. They are sequential, but I was also wondering if concurrent requests may cause Init to be called twice.
@Jinhuafei is it guaranteed that Application.Init is never called in parallel?
There was a problem hiding this comment.
Even if it's called in parallel you do not do any harm by making reflection call twice
There was a problem hiding this comment.
You can set onStepMethodInfo in the static constructor.
Fixes microsoft/ApplicationInsights-dotnet-server#797.
Until we can restore Activity without creating a child, we have to notify tracing system about the new Activity.
Otherwise, dependency calls made in the scope of the request becomes grandchildren of the request and tracing system might not be able to properly correlate them.
This PR attempts to restore Activity in ExecuteRequestHandler step (if lost) and notifies about it in End_Request