Skip to content
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

gunicorn + uvicorn + ASGI + flask is not working #2153

Open
sundarv85 opened this issue Nov 4, 2024 · 2 comments
Open

gunicorn + uvicorn + ASGI + flask is not working #2153

sundarv85 opened this issue Nov 4, 2024 · 2 comments
Labels
agent-python community Issues opened by the community triage Issues awaiting triage

Comments

@sundarv85
Copy link

Describe the bug:

When I run as gunicorn -w 4 run:app using its own wsgi, then I see data in Kibana.

When I run as gunicorn -w 4 -k uvicorn.workers.UvicornWorker run:asgi_app, then I do not see the transactions showing up.

To Reproduce

  1. Please use this repo: https://github.com/helloflask/flask-examples
  2. cd http
  3. Add a new file run.py with the contents to convert flask WSGI to ASGI
from app import app
from asgiref.wsgi import WsgiToAsgi

# Convert the Flask WSGI app to ASGI
asgi_app = WsgiToAsgi(app)

if __name__ == '__main__':
    app.run(debug=True)

  1. Now run with gunicorn -w 4 run:app or gunicorn -w 4 -k uvicorn.workers.UvicornWorker run:asgi_app
  2. Now access http://127.0.0.1:8000 - once with just gunicorn and once with uvicorn
  3. You will notice that with gunicorn, the transactions are captured, but with uvicorn, then home page transaction is not captured.
  4. OS: [e.g. Mac]
  • Python version: 3.11.6
  • Framework and version: Flask
  • Agent version: Latest

It seems related to #1331

@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Nov 4, 2024
@xrmx
Copy link
Member

xrmx commented Nov 4, 2024

Thanks for reporting. What's the reason to run a wsgi framework in an asgi worker?

@sundarv85
Copy link
Author

sundarv85 commented Nov 5, 2024

One of our teammates reported the issue and they use asgi with flask. And they reported that the issue happens only with uvicorn. So I just used this sample app to re-create the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-python community Issues opened by the community triage Issues awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants