elastic / elastic/apm-agent-python

Celery task context sticks to the main transaction which is misleading

オープン
#2,302 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
agent-python community triage
主要言語
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.

![Image](https://github.com/user-attachments/assets/a232fb26-c5ba-4a3b-82d0-1717f8952365)

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

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

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