elastic / elastic/apm-agent-python
Celery task context sticks to the main transaction which is misleading
- Langage dominant
- Python
- Étoiles
- 431
- Forks
- 239
- Merge moyen
- 5 j 10 h
- PR mergées (30 j)
- 7
Description
**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.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Reproduire avec Django 5, Python 3.11, elastic-apm 6.23.0 et Celery 5.5.1, en plaçant elasticapm.contrib.django.middleware.TracingMiddleware en premier et en invoquant les tâches via .apply_async et .delay(). Comparer le timing et le contexte des transactions de la tâche et de la vue ; c’est terminé lorsque la tâche est affichée indépendamment après la réponse de la vue, au lieu de rester attachée à la transaction principale de la vue.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- django, python
- Domaine
- backend, observability
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100