Issue with passing trace_entity when using ThreadPoolExecutor in lambda
- Vorherrschende Sprache
- Python
- Sterne
- 338
- Forks
- 147
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
```
Beitragsleitfaden
Rechercherichtung
Beginne mit dem ThreadPoolExecutor-Beispiel in der README und untersuche die für Lambdas verwendete benutzerdefinierte Kontextklasse, insbesondere wie Trace-Entities initialisiert und gesetzt werden. Reproduziere den ersten von einem Thread bearbeiteten Job und verifiziere, dass sein Subsegment an die bereitgestellte Trace-Entity angehängt wird, ohne dass zuvor ein get_trace_entity-Aufruf erforderlich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- aws, python
- Bereich
- observability-sre
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100