MongoDB.Driver.Core.Extensions.DiagnosticSources icon indicating copy to clipboard operation
MongoDB.Driver.Core.Extensions.DiagnosticSources copied to clipboard

Trying to set an Activity that is not running

Open glucaci opened this issue 1 year ago • 1 comments

Hi, could you please release the current master version ?

Thanks!

glucaci avatar Jul 10 '24 19:07 glucaci

Hmm... seams that the error that i get is still in master.

System.InvalidOperationException: 'Trying to set an Activity that is not running'

In the Handle methods we always Stop the activity in the delegate from the WithReplacedActivityCurrent and this means that the finally from WithReplacedActivityCurrent will set to the Activity.Current a stopped activity and will throw because => https://github.com/dotnet/runtime/blob/041375910885f3a30ccf0bb8b751566dae7043f4/src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Activity.cs#L1378

If there is no reason to call Stop in the delegate we could put it after WithReplacedActivityCurrent.

Or if there is no reason to use WithReplacedActivityCurrent we could just remove it.

glucaci avatar Jul 10 '24 20:07 glucaci

Fixed by #32

jbogard avatar Aug 12 '24 18:08 jbogard