jbogard / MongoDB.Driver.Core.Extensions.DiagnosticSources

Apache License 2.0
44 stars 18 forks source link

Trying to set an Activity that is not running #33

Closed glucaci closed 3 weeks ago

glucaci commented 1 month ago

Hi, could you please release the current master version ?

Thanks!

glucaci commented 1 month ago

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.

jbogard commented 3 weeks ago

Fixed by #32