elastic / elastic/apm-agent-python
Celery task context sticks to the main transaction which is misleading
- 主要言語
- Python
- スター
- 431
- フォーク
- 239
- 平均マージ
- 5日 10時間
- マージ済み PR(30日)
- 7
説明
**Describe the bug**: ...
Celery task execution sticks to the main transaction of the django view. This is really misleading cause you may think that your view\endpoint works really slow, but in reality user already received response.

**Environment (please complete the following information)**
- OS: Linux (heroku)
- Python version: 3.11
- Framework and version [e.g. Django 2.1]: Django 5
- APM Server version:
- Agent version: elastic-apm = "^6.23.0"
- Celery celery = {extras = ["sqs"], version = "^5.5.1"}
**Additional context**
`elasticapm.contrib.django.middleware.TracingMiddleware` middleware in the beginning (first).
Celery task is called trough .apply_async or .delay() doesn't matter.
Any ideas why it may happen? I assume it should be displayed just like it was called and that's it, without internal context sticked to the main View\endpoint transaction.
コントリビューションガイド
調査の方向性
Django 5、Python 3.11、elastic-apm 6.23.0、Celery 5.5.1で再現し、elasticapm.contrib.django.middleware.TracingMiddlewareを最初に配置して、タスクを.apply_asyncと.delay()の両方から呼び出す。タスクとビューのトランザクションのタイミングとコンテキストを比較する。完了条件は、タスクがメインのビューのトランザクションに引き続き紐付いたままではなく、ビューのレスポンス後に独立して表示されることとする。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- django, python
- 領域
- backend, observability
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100