aws / aws/aws-xray-sdk-python

Support boto3 S3 transfer manager

Open
#52 14 comments 15 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
338
Forks
147
PR merge metrics
No merged PRs in 30d

Description

[boto3](https://github.com/boto/boto3) has a few high-level S3 API calls like `upload_file`, `download_file` which depends on [s3transfer](https://github.com/boto/s3transfer) to perform multi-threaded object puts/gets to increase through put. This will result in a `SegmentNotFoundException` as the X-Ray recorder tries to capture the "real" S3 API call but it loses the context because the actual http call is in a worker thread from the thread pool.

The S3 transfer manager under the hood uses `futures.ThreadPoolExecutor` per https://github.com/boto/s3transfer/blob/develop/s3transfer/futures.py#L370 but there is no proper API on `boto3` client level to propagate context from user code. And requiring user code changes is not a good customer experience.

The SDK should somehow monkey-patch S3 transfer manager so that it automatically propagate context to all worker threads so each http outbound call is captured and attached to its parent segment or subsegment properly.

Library `django-storages` or any storage library that supports S3 as back-end and uses `boto3` certain APIs might face the same issue.

More detailed technical deep dive could be found here: https://github.com/aws/aws-xray-sdk-python/issues/4.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.