Issue with passing trace_entity when using ThreadPoolExecutor in lambda
- Langage dominant
- Python
- Étoiles
- 338
- Forks
- 147
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I followed the instructions in the readme for passing the trace entity in a ThreadPoolExecutor but this does not appear to work properly in a lambda. The first time a thread does some work the trace_entity does not stick and the subsegment gets put under the root node not the one it should be assiciated with. The next time a thread picks up a job everything seems to operate fine.
I dug into the code a bit and it seems like there is a custome context class for lambdas but it does not override `set_trace_entity` to work properly with the other changes in the class. To workaround the issue I have found calling `get_trace_entity` before setting sets the internal state up properly.
example workaround from readme
```
def load_url(url, trace_entity):
xray_recorder.get_trace_entity() # Workaround to setup internal state
xray_recorder.set_trace_entity(trace_entity)
resp = requests.get(url)
xray_recorder.clear_trace_entities()
return resp
```
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par l’exemple de ThreadPoolExecutor du README et examinez la classe de contexte personnalisée utilisée pour les lambdas, en particulier la manière dont les entités de trace sont initialisées et définies. Reproduisez le premier travail pris en charge par un thread et vérifiez que son sous-segment est attaché à l’entité de trace fournie sans nécessiter d’appel préalable à get_trace_entity.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- aws, python
- Domaine
- observability-sre
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100