Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

in_segment_async doesn't get/pass the current Lambda segment

Aperta
#349 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia riproducendo il flusso API Gateway to Lambda descritto qui, quindi esamina xray_recorder.in_segment_async, get_trace_entity, current_segment e AsyncContext. Confronta il comportamento con la discussione nell’issue 310. Il lavoro è completato quando il segmento asincrono rimane connesso alla traccia Lambda senza il workaround e senza un errore NoneType per trace_id.

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

Descrizione

Hello,
I am opening this issue on request of @NathanielRN after a discussion with him in https://github.com/aws/aws-xray-sdk-python/issues/310 .

The problem is that when we have API GW -> Lambda invocation and in the Lambda we use async , then we get 2 separate traces. One from API GW to Lambda and another from in_segment_async . To tie them together I have to use the following workaround:

    # get current segment
    trace_id = xray_recorder.get_trace_entity().trace_id
    parent_id = xray_recorder.current_segment().id
    # enable xray to work with async
    # even though Lambda has its own segment we need to create one async segment
    xray_recorder.configure(context=AsyncContext())
    async with xray_recorder.in_segment_async('add_brochure', traceid=trace_id, parent_id=parent_id) as segment:
       ...

But even then most of the times (usually works first time after deployment only) it doesn't work because I get the error:

[ERROR] AttributeError: 'NoneType' object has no attribute 'trace_id'
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 19, in lambda_handler
    trace_id = xray_recorder.get_trace_entity().trace_id
Lingua principale
Python
Stelle
339
Fork
147
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di aws/aws-xray-sdk-python

Tutte le issue di aws/aws-xray-sdk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.