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
This example https://github.com/opentracing-contrib/python-flask/blob/master/example/server.py#L28 uses the tracer returned by jaeger_client's initialize_tracer method. This method internally sets the opentracing.tracer to jaeger tracer object, this means for any request handler there after can do opentracing.global_tracer().start_span(...) and this sends traces to jaeger
I noticed when i run a flask dev server(using app.run) opentracing.global_tracer() is not the same as jaeger tracer i initialised earlier(as in the the link above) when starting up the server. Is there something i'm missing on flask side?
I could use returned jaeger_tracer from initialize_tracer(), which would mean i'd have to pass this around or create my own process/request local storage. I suppose according to jaeger tracer docs https://github.com/jaegertracing/jaeger-client-python#production, the initialised jaeger tracer must be available via opentracing.global_tracer()
The text was updated successfully, but these errors were encountered:
I was able to solve this by setting up a uwsgi.ini to start up the server, and use @postfork from uwsgidecorators to ensure the tracer is initialized once per forked process. I suppose, this is more of a production way to set things up
The dev server issue still remains though, Afaik the app.run way to start up flask dev server creates one process so i expect the tracer to work there without @postfork. I even tried app.run(threaded=False, ...) with no luck
I was able to solve this by setting up a uwsgi.ini to start up the server, and use @postfork from uwsgidecorators to ensure the tracer is initialized once per forked process. I suppose, this is more of a production way to set things up
@jan25 , Could you please share an example of a @postfork function that worked? I have tried the following and it fails:
This example https://github.com/opentracing-contrib/python-flask/blob/master/example/server.py#L28 uses the tracer returned by jaeger_client's
initialize_tracer
method. This method internally sets theopentracing.tracer
to jaeger tracer object, this means for any request handler there after can doopentracing.global_tracer().start_span(...)
and this sends traces to jaegerI noticed when i run a flask dev server(using
app.run
)opentracing.global_tracer()
is not the same as jaeger tracer i initialised earlier(as in the the link above) when starting up the server. Is there something i'm missing on flask side?I could use returned
jaeger_tracer
frominitialize_tracer()
, which would mean i'd have to pass this around or create my own process/request local storage. I suppose according to jaeger tracer docs https://github.com/jaegertracing/jaeger-client-python#production, the initialised jaeger tracer must be available viaopentracing.global_tracer()
The text was updated successfully, but these errors were encountered: