elastic / elastic/apm-agent-python

gunicorn + uvicorn + ASGI + flask is not working

オープン
#2,153 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
agent-python community triage
主要言語
Python
スター
431
フォーク
239
平均マージ
5日 10時間
マージ済み PR(30日)
7

説明

**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)

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

It seems related to #1331

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。