You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The BatchSpanProcessor is not fork-safe and doesn’t work well with application servers (Gunicorn, uWSGI) which are based on the pre-fork web server model. The BatchSpanProcessor spawns a thread to run in the background to export spans to the telemetry backend. During the fork, the child process inherits the lock which is held by the parent process and deadlock occurs. We can use fork hooks to get around this limitation of the span processor.
The recommended solution in [1] for gunicorn doesn't seem to work if autoinstrumentation was used to launch gunicorn. A warning is thrown indicating that the TraceProvider cannot be overriden ("Overriding of current TracerProvider is not allowed"). See [1].
After some experimentation, I found that if I call shutdown() on the current TracerProvider object and then reinitialize all Exporters, it seems to work in the child workers of gunicorn.
Use Case
The BatchSpanProcessor is not fork-safe and doesn’t work well with application servers (Gunicorn, uWSGI) which are based on the pre-fork web server model. The BatchSpanProcessor spawns a thread to run in the background to export spans to the telemetry backend. During the fork, the child process inherits the lock which is held by the parent process and deadlock occurs. We can use fork hooks to get around this limitation of the span processor.
See [1] for more information.
Reference:
[1] https://opentelemetry-python.readthedocs.io/en/stable/examples/fork-process-model/README.html
Proposal
Implement solution outlined in [1].
The text was updated successfully, but these errors were encountered: