Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

in_segment_async doesn't get/pass the current Lambda segment

オープン
#349 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
aws, python

調査の方向性

まず、ここで説明されている API Gateway to Lambda のフローを再現し、その後 xray_recorder.in_segment_async、get_trace_entity、current_segment、AsyncContext を調査します。issue 310 の議論と動作を比較します。workaround なしで非同期セグメントが Lambda のトレースに接続されたままになり、NoneType の trace_id エラーが発生しなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
340
フォーク
148
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws/aws-xray-sdk-python のほかの issue

aws/aws-xray-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。