aws / aws/aws-xray-sdk-python

Is Python multiprocessing supported?

オープン
#232 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
338
フォーク
147
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

I've been trying to get AWS X-Ray working in my Python application where I spin up separate Python processes via Pool() and apply_async. I'm passing in the segment from .get_trace_entity and setting it in the child process, but I'm still getting exceptions that seem to suggest the segment isn't getting passed properly, e.g.:
```
2020-07-08 15:57:54,703] {{taskinstance.py:1088}} ERROR - 'Segment' object has no attribute 'sampled'
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.7/site-packages/xxxx-0.1-py3.7.egg/xxxx/elt/extract/kinesis_handler.py", line 52, in push_to_kinesis
xray_recorder.begin_subsegment('push_to_kinesis')
File "/usr/local/lib/python3.7/site-packages/aws_xray_sdk/core/recorder.py", line 297, in begin_subsegment
if not segment.sampled:
AttributeError: 'Segment' object has no attribute 'sampled'
"""
```

Does X-Ray support tracking segments through separate processes, or am I just doing something wrong? I noticed in the documentation it only mentions ThreadPoolExecutor, and I know sharing state with separate processes can be a bit fiddly due to pickling.

Thanks in advance!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

ThreadPoolExecutor と recorder のエントリーポイントである get_trace_entity および begin_subsegment に言及しているドキュメントのセクションから始めてください。Issue に記載されている Pool() と apply_async のケースを再現し、その後、別プロセスの tracing がサポートされているか、またはどのような動作をドキュメント化する必要があるかを判断してください。このユースケースについて明確でテスト済みの回答が得られれば完了です。

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

評価

技術スタック
aws, python
領域
backend, observability-sre
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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