-
Notifications
You must be signed in to change notification settings - Fork 703
added gunicorn production server documentation #1272
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,17 @@ def hello(): | |
application = get_wsgi_application() | ||
application = OpenTelemetryMiddleware(application) | ||
|
||
|
||
Usage in Production Server (gunicorn) | ||
------------------------------------ | ||
|
||
Modify the ``gunicorn.config.py`` file as shown below. | ||
|
||
.. code-block:: python | ||
|
||
def post_fork(server, worker): | ||
worker(DjangoInstrumentor().instrument()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right actually. I was thinking about that too but I thought instrumentation should pass through a worker. I see now and agree that passing it into post_fork is quite sufficient There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you suggesting that I create a pipeline in post_fork? I was thinking more of using opentelemetry as an agent. I could be wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that you recommended a pipeline. Let me put that in effect. |
||
|
||
API | ||
--- | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen some problems regarding the forking process of Gunicorn when working with Opencensus like here and here. The main issue was that the worker thread that was responsible for sending spans to the exporter (BatchSpanProcessor in this case) was not copied to the child processes due to Gunicorn using
os.fork()
to spawn them. Does thispost_fork()
configuration fix this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, this is not enough. The entire trace pipeline (particularly batch processor) needs to be setup in post_fork for it to work.