aws / aws/aws-xray-sdk-python

Issue with passing trace_entity when using ThreadPoolExecutor in lambda

Aperta
#342 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
338
Fork
147
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con l'esempio di ThreadPoolExecutor nel README e analizza la classe di contesto personalizzata utilizzata per le lambda, in particolare il modo in cui le entità di traccia vengono inizializzate e impostate. Riproduci il primo job gestito da un thread e verifica che il suo sottosegmento sia associato all'entità di traccia fornita senza bisogno di una chiamata preliminare a get_trace_entity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
aws, python
Ambito
observability-sre
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.