aws / aws/aws-xray-sdk-python

Issue with passing trace_entity when using ThreadPoolExecutor in lambda

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

Mô tả

I followed the instructions in the readme for passing the trace entity in a ThreadPoolExecutor but this does not appear to work properly in a lambda. The first time a thread does some work the trace_entity does not stick and the subsegment gets put under the root node not the one it should be assiciated with. The next time a thread picks up a job everything seems to operate fine.

I dug into the code a bit and it seems like there is a custome context class for lambdas but it does not override `set_trace_entity` to work properly with the other changes in the class. To workaround the issue I have found calling `get_trace_entity` before setting sets the internal state up properly.

example workaround from readme
```
def load_url(url, trace_entity):
xray_recorder.get_trace_entity() # Workaround to setup internal state
xray_recorder.set_trace_entity(trace_entity)

resp = requests.get(url)

xray_recorder.clear_trace_entities()
return resp
```

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 ví dụ ThreadPoolExecutor trong README và kiểm tra lớp ngữ cảnh tùy chỉnh được sử dụng cho các lambda, đặc biệt là cách các trace entity được khởi tạo và thiết lập. Tái hiện job đầu tiên được một thread xử lý và xác minh rằng subsegment của nó được gắn vào trace entity được cung cấp mà không cần gọi get_trace_entity trước đó.

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
observability-sre
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/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.