elastic / elastic/apm-agent-python
gunicorn + uvicorn + ASGI + flask is not working
- Ngôn ngữ chính
- Python
- Star
- 431
- Fork
- 239
- Merge trung bình
- 5 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 7
Mô tả
**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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với việc tái hiện run.py trong ví dụ http của helloflask/flask-examples và so sánh hai lệnh Gunicorn được nêu trong issue. Xác minh việc thu thập transaction đối với ứng dụng Flask WSGI so với ứng dụng được bọc bằng WsgiToAsgi, sau đó kiểm tra issue liên quan #1331. Hoàn tất khi lần chạy ASGI thu thập transaction của trang chủ giống như lần chạy WSGI.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- flask, python
- Lĩnh vực
- backend, observability
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100