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

Django gunicorn auto instrumentation

Open anirudhbagri opened this issue 2 years ago • 6 comments

Currently, Django autoinstrumentation supports flask and uWSGI servers. However, when running django app using gunicorn server, the autoinstrumentation does not work.

This is the command I am trying to run.

opentelemetry-instrument --trace-exporter zipkin_json python3.8 gunicorn ${DJANGO_WSGI_MODULE}:application --name ${NAME} --bind=127.0.0.1:80 --preload The app starts fine, but doesn't report any traces to zipkin.

anirudhbagri avatar Aug 13 '21 10:08 anirudhbagri

It is not supported by the opentelemetry-instrument command. Docs mention it and explain how to instrument gunicorn based services: https://opentelemetry-python.readthedocs.io/en/latest/examples/fork-process-model/README.html?highlight=gunicorn#working-with-fork-process-models

owais avatar Aug 17 '21 10:08 owais

I'd like to leave this open in the hope of adding native support for gunicorn to the opentelemetry-instrument command.

owais avatar Aug 17 '21 10:08 owais

AFAIK, even the post_fork hook doesn't work with auto-instrumentation using the way it is explained in the docs. The doc explains manual way of instrumenting. Probably we can update the docs to explain how to auto-instrument guincorn based services as well.

we need to add the following to initialize auto-instrumentation

from opentelemetry.instrumentation.auto_instrumentation import sitecustomize in the post_fork method.

anirudhbagri avatar Aug 17 '21 11:08 anirudhbagri

I remember using Gunicorn with auto instrumentation and see it emit traces while debugging some issue.

srikanthccv avatar Aug 17 '21 15:08 srikanthccv

Any update on this making to the next version.

debu999 avatar Oct 19 '21 02:10 debu999

Does open-telemetry support manual instrumentation for Gunicorn then?

yimipeng avatar Mar 20 '22 04:03 yimipeng