-
Notifications
You must be signed in to change notification settings - Fork 53
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
Initialization of the global tracer #23
Comments
Fixed by #29 @mikebryant Let me know if you have any opinion or feedback on this ;) |
Setting a tracer object yourself can be pretty hard, in a Django environment. You need to be able to have that happen lazily, after forking has happened (see all the issues with Jaeger) Expecting the user to initialise the tracer themselves in the settings module means it's impossible to use - there's no way of initialising the tracer at the right time. |
Have you got an example of being able to use Jaeger with Django under mod_wsgi using the approach you're proposing? |
Not really. I went through https://github.com/jaegertracing/jaeger-client-python/issues and didn't manage to find a related one...
So I haven't set up Django + mod_wsgi myself, but some (production) cases I have found work by putting all the parameters needed for initializing your tracer right in
One alternative I see nevertheless is providing, based on very Django's needs, a callback at OPENTRACING_TRACER_INIT_CB = my_init_cb
# In some place:
def my_init_cb(django_tracer):
opentracing.tracer = django_tracer._tracer Would that work? |
@mikebryant Guess you were talking about #14 ? ;) |
I believe the issue was jaegertracing/jaeger-client-python#60, leading to deadlocks when the tracer initialisation was done in settings.py The problem as I recall is needing to start the event loop after forking, which can't be done in settings.py, as that's read pre-fork. My requirements are fairly simple, I want to be able to have static Django settings that just work, and I don't really want to have to stick python code somewhere to set up the global tracer object.
|
Sadly this could be requested in any instrumentation library (gevent, asyncio, tornado, sqlalchemy, you name it). This wouldn't scale. And in Java, C# and Javascript the duty of the developer is to take the extra steps to write code to set the global In any case, I think at least I'd like to have this as an optional I will cook re-work so initializing this one is at least optional. |
I don't mind having it hidden behind a setting. I can put this another way, we have many django projects deployed, and I don't want to write code repeatedly. The last time I tried setting this up, I found that I couldn't instantiate the Jaeger tracing object in settings.py without deadlocking the system. And writing my own lazy initialization middleware in every project isn't optimal, so I want to push it back upstream, so there's a simple way of making Jaeger work. As long as it's simple and obvious to set up this library in a way that satisfies the following requirements, I'll be happy
(Not saying the library must do both of those in all cases, but I don't want to need to write more than a few lines of code in every single project to achieve this |
#30 should do it. @mikebryant take a look whenever you have time, please. |
Closing as #30 handles this issue by making this bit optional. |
Hey @mikebryant
I was checking the initialization of the global tracer, and I'm not sure this is the right approach. Specifically this is the part I'm talking about:
Usually, they way we have done things for other instrumentation in Java, is to do it the other way around: if the user doesn't specify explicitly a
tracer
(throughOPENTRACING_TRACER
orOPENTRACING_TRACER_CALLABLE
in this case), then fallback toopentracing.tracer
).Setting the
opentracing.tracer
instance right frompython-django
kinda breaks the contract, and I'm afraid that the user won't be able to set the globaltracer
himself if we do this - and also, I'm afraid other instrumentation libraries may also want to setopentracing.tracer
each, and we end up in an override cascade.Is there any need from your part to have this code running? Let me know, and maybe we can find a solution in the middle ;)
The text was updated successfully, but these errors were encountered: