This check doesn't guarantee it only executes once. You could use the Once class to make it safe, but then you'll still have the same race on L118. You could modify Once to allow passing in a lock object (similar to how threading.Condition accepts an optional Lock object) and reuse it on L118 or inline the logic in Once here to make this all thread safe.
We actually have the same bug in the tracing SDK.
Feel free to open an issue for this and address in a separate PR
Originally posted by @aabmass in #2227 (comment)
This check doesn't guarantee it only executes once. You could use the
Onceclass to make it safe, but then you'll still have the same race on L118. You could modifyOnceto allow passing in a lock object (similar to howthreading.Conditionaccepts an optional Lock object) and reuse it on L118 or inline the logic inOncehere to make this all thread safe.We actually have the same bug in the tracing SDK.
Feel free to open an issue for this and address in a separate PR
Originally posted by @aabmass in #2227 (comment)