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

Document how to create new subsegments inside a ThreadPoolExecutor thread

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
aws, python
領域
documentation

調査の方向性

Issue にリンクされているスレッド処理のドキュメントから始め、set_trace_entity の後にある capture と in_segment のエントリーポイントを確認してください。ワーカースレッドでサブセグメントを作成するためにサポートされているパターンを、クリーンアップも含めて明確にし、読者が有効なアプローチを区別できるように例を更新してください。

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

説明

documentation

The current documentation shows how to set the parent thread's X-ray entity in the worker thread:

def load_url(url, trace_entity):
    # Set the parent X-Ray entity for the worker thread.
    xray_recorder.set_trace_entity(trace_entity)
    # Subsegment captured from the following HTTP GET will be
    # a child of parent entity passed from the main thread.
    resp = requests.get(url)
    # prevent thread pollution
    xray_recorder.clear_trace_entities()
    return resp

However it's not clear how this interacts with capture/in_segment. For example, I assume this isn't correct, as the capture starts before we call set_trace_entity:

@xray_recorder.capture('subsegment_name')
def load_url(url, trace_entity):
    # Set the parent X-Ray entity for the worker thread.
    xray_recorder.set_trace_entity(trace_entity)
    # Subsegment captured from the following HTTP GET will be
    # a child of parent entity passed from the main thread.
    resp = requests.get(url)
    # prevent thread pollution
    xray_recorder.clear_trace_entities()
    return resp

However, are these two OK?

def load_url(url, trace_entity):
    # Set the parent X-Ray entity for the worker thread.
    xray_recorder.set_trace_entity(trace_entity)
    with xray_recorder.capture('subsegment_name'):
        # Subsegment captured from the following HTTP GET will be
        # a child of parent entity passed from the main thread.
        resp = requests.get(url)
    # prevent thread pollution
    xray_recorder.clear_trace_entities()
    return resp
def load_url(url, trace_entity):
    # Set the parent X-Ray entity for the worker thread.
    xray_recorder.set_trace_entity(trace_entity)
    with xray_recorder.in_segment('segment_name') as segment:
        segment.put_metadata('key', dict, 'namespace')
        # Subsegment captured from the following HTTP GET will be
        # a child of parent entity passed from the main thread.
        resp = requests.get(url)
    # prevent thread pollution
    xray_recorder.clear_trace_entities()
    return resp

It would be great if the docs on threading had a more complete example.

主要言語
Python
スター
339
フォーク
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 を短くまとめたダイジェスト。