The problem is that DiagnosticsActivityEventSubscriber wants to return previously captured current activity to Activity.Current property again. In the Activity.Current setter there is a check that fails when the activity is stopped. When the "parent" activity is stopped in the meanwhile, exception is thrown.
The same code raises the exception also when you call a sync version of a mongo command. In this case, command's activity is the same as the Activity.Current activity. Inside action(), activity gets stopped, and afterwards activity is again assigned to Activity.Current property.
Hello.
This PR resolves issue #30.
The problem is that
DiagnosticsActivityEventSubscriber
wants to return previously captured current activity toActivity.Current
property again. In theActivity.Current
setter there is a check that fails when the activity is stopped. When the "parent" activity is stopped in the meanwhile, exception is thrown.The same code raises the exception also when you call a sync version of a mongo command. In this case, command's activity is the same as the
Activity.Current
activity. Insideaction()
, activity gets stopped, and afterwards activity is again assigned toActivity.Current
property.Both issues should be fixed by this PR.
Thanks.