aws / aws/aws-xray-sdk-python

Is Python multiprocessing supported?

Đang mở
#232 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
338
Fork
147
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với phần tài liệu đề cập đến ThreadPoolExecutor và các điểm đầu vào của recorder là get_trace_entity và begin_subsegment. Tái hiện trường hợp Pool() và apply_async được mô tả trong issue, sau đó xác định liệu việc tracing trong các process riêng biệt có được hỗ trợ hay không, hoặc hành vi nào cần được ghi lại trong tài liệu; hoàn thành khi có câu trả lời rõ ràng, đã được kiểm thử cho trường hợp sử dụng này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
aws, python
Lĩnh vực
backend, observability-sre
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.