Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition in set_tracer_provider() #2181

Closed
aabmass opened this issue Oct 5, 2021 · 0 comments · Fixed by #2182
Closed

Race condition in set_tracer_provider() #2181

aabmass opened this issue Oct 5, 2021 · 0 comments · Fixed by #2182
Assignees
Labels
bug Something isn't working

Comments

@aabmass
Copy link
Member

aabmass commented Oct 5, 2021

An unlikely race condition exists where multiple threads can set the global tracer provider at once, bypassing the check that the global tracer provider is only set once (code). This code needs a lock to prevent this condition:

if _TRACER_PROVIDER is not None:
logger.warning("Overriding of current TracerProvider is not allowed")
return
_TRACER_PROVIDER = tracer_provider

Describe your environment N/A

Steps to reproduce
Difficult to reproduce (race condition)

What is the expected behavior?
You can only configure the global tracer provider exactly once. All existing ProxyTracer instances should now proxy through this single global.

What is the actual behavior?
Global tracer provider could be set more than once if multiple threads attempt to do so. That could lead some ProxyTracer instances to cache a _real_tracer from a stale tracer provider and that Telemetry is lost or misconfigured.

Additional context
Ran into this while working on proxying for metrics.

@aabmass aabmass added the bug Something isn't working label Oct 5, 2021
@aabmass aabmass self-assigned this Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant