Segment context not propagated when `asyncio.run_in_executor` is used
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- aws, python
- Domain
- backend, observability-sre
Research direction
Start with the README's guidance on thread-pool trace propagation and the AsyncContext entry point used with loop.run_in_executor. Reproduce the minimized example, then trace how run_task obtains the current segment and verify that the example completes without missing-segment or missing-subsegment messages when propagation is automatic.
Written by the indexing model from the issue text.
Description
(Minimised) Example code:
import asyncio
from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
from aws_xray_sdk.core.async_context import AsyncContext
import boto3
xray_recorder.configure(service="Test app", sampling=False, context=AsyncContext())
patch_all()
def run_task():
s3_client = boto3.client("s3")
s3_client.list_buckets()
async def main():
loop = asyncio.get_running_loop()
xray_recorder.begin_segment("test")
await loop.run_in_executor(None, run_task)
xray_recorder.end_segment()
asyncio.run(main())
Output:
cannot find the current segment/subsegment, please make sure you have a segment open
No segment found, cannot begin subsegment s3.
cannot find the current segment/subsegment, please make sure you have a segment open
cannot find the current segment/subsegment, please make sure you have a segment open
No segment to end
cannot find the current segment/subsegment, please make sure you have a segment open
I understand from the README that when using a thread pool (which is the default executor), the trace entity needs to be manually propagated. Could it be propagated automatically?
I'm asking because in the use case I have, a 3rd party library I'm using is making the call so I couldn't patch the call sites easily.
- Dominant language
- Python
- Stars
- 339
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/aws-xray-sdk-python
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
aws/aws-xray-sdk-python#490 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 1/100
aws/aws-xray-sdk-python#460 ·
-
Next releaseOpen
Difficulty 5/5 Over a week Newbie friendliness 20/100
aws/aws-xray-sdk-python#457 · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
aws/aws-xray-sdk-python#453 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
aws/aws-xray-sdk-python#452 · 1 reaction ·
All issues in aws/aws-xray-sdk-python
Similar issues
-
feature:LinkChecker
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
digitalfabrik/integreat-cms#4594 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
EleutherAI/lm-evaluation-harness#4319 ·
Maintainers usually reply within 1 day
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
json_params_matcher fails on falsy top-level JSON primitives (0, False, "")Possibly taken @mayureshsonawane17 claimed this today. OpenWaiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 5 days