jbogard / MongoDB.Driver.Core.Extensions.DiagnosticSources

Apache License 2.0
46 stars 18 forks source link

Replacing Activity.Current to handle a case of async Mongo commands #5

Closed dgrozenok closed 3 years ago

dgrozenok commented 3 years ago

Due to the async MongoDb commands not sticking to the same async flow the Activity.Current could be changed when the CommandSucceededEvent or CommandFailedEvent are handled. In order for the span to end correctly the change is replacing the Activity.Current, ends the span and then restores the Activity.Current to the previous state.