python-django icon indicating copy to clipboard operation
python-django copied to clipboard

Lazily initialize tracer for Jaeger/1.10 compatibility

Open benjigoldberg opened this issue 7 years ago • 7 comments

When running The Jaeger Python Client with this library, the initialization step hangs indefinitely with Django 1.10.

@mikebryant if you take your example OpenTracing/Jaeger Django project and upgrade Django to >=1.10 and try running, the server will fail to start.

I believe this comes down to the way in which Django changed the initialization of Middleware. In versions prior to Django 1.10, the middleware wouldnt be initialized until the first request. In Django 1.10+, the middleware is initialized on start. Initializing the Jaeger tracer before the first request causes the Jaeger client to deadlock -- check out Jaeger Issue 31 and Jaeger Issue 60.

This change simply forces the initialization to happen once on the first request, thus avoiding the above behavior.

benjigoldberg avatar Jan 08 '18 14:01 benjigoldberg

@mikebryant ^^

SEJeff avatar Apr 12 '18 14:04 SEJeff

Is there anything preventing this from being accepted, @mikebryant? It doesn't seem to introduce any long term overhead for apps or tracers and is necessary for the jaeger client to work in django.

rmfitzpatrick avatar Sep 19 '18 14:09 rmfitzpatrick

ugh, I'm really sorry. I've been overloaded with other stuff and missed this.

Thanks for pinging me about this!

mikebryant avatar Sep 19 '18 15:09 mikebryant

Ping :)

naphthalene avatar Oct 16 '18 17:10 naphthalene

@carlosalberto, @benjigoldberg if it's any help I was able to get this working against master w/ these changes: https://github.com/rmfitzpatrick/python-django/commit/301045b6a27dcd0ecb87f0a7f743ccbe2f5ec207.

rmfitzpatrick avatar Nov 20 '18 19:11 rmfitzpatrick

Hi folks,

It would be great to see rmfitzpatrick@301045b cherry-picked into master. Thank you for the effort, @benjigoldberg and @rmfitzpatrick!

Jamim avatar Nov 22 '18 15:11 Jamim

Hi guys, any update 💃

vinhlh avatar Dec 21 '18 10:12 vinhlh