Bug: nested subsegments don't work across threads
@srprash is already working on this.
Since Sep 28, 2023.
Assessment
This issue has not been assessed yet.
Description
We're tracking a bug where nested subsegments don't work across threads, even when using the official suggestion in the documentation.
We've managed to reproduce the issue with some minimal code:
Code snippet
from concurrent.futures import ThreadPoolExecutor
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("## lambda handler")
def lambda_handler(event, context):
with ThreadPoolExecutor() as pool:
@xray_recorder.capture("## f")
def f():
@xray_recorder.capture("## h")
def h():
pass
def g(trace_entity):
xray_recorder.set_trace_entity(trace_entity)
h()
xray_recorder.clear_trace_entities()
curr = xray_recorder.get_trace_entity()
pool.submit(g, curr)
This produces the following XRay traces:
XRay trace
XRay Event at (2023-04-05T16:32:52.012000) with id (1-642d8694-731f0a1a6d204264677086db) and duration (0.388s)
- 0.388s - lambda-function-url-HelloWorldFunction-sRQB00cHvXOP [HTTP: 200]
- 0.021s - lambda-function-url-HelloWorldFunction-sRQB00cHvXOP
- 0.223s - Initialization
- 0.020s - Invocation
- 0.019s - ## lambda handler
- 0.018s - ## f
- 0.000s - ## h
- 0.000s - Overhead
The expected output would be for the "h" trace to be nested under "f":
Expected output
XRay Event at (2023-04-05T16:32:52.012000) with id (1-642d8694-731f0a1a6d204264677086db) and duration (0.388s)
- 0.388s - lambda-function-url-HelloWorldFunction-sRQB00cHvXOP [HTTP: 200]
- 0.021s - lambda-function-url-HelloWorldFunction-sRQB00cHvXOP
- 0.223s - Initialization
- 0.020s - Invocation
- 0.019s - ## lambda handler
- 0.018s - ## f
- 0.000s - ## h
- 0.000s - Overhead
- 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
-
jobs restart --verify: hotlane restart timeout (10s) shorter than its shutdown (~30s) → false exit 1Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
EtanHey/brainlayer#1072 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
_apply_doc_content: a cancel during the shielded image gather still sends the content batchUpdateOpenenhancement
Difficulty 2/5 Under an hour Newbie friendliness 80/100
khuisman/mcp-gee-sweet#904 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 70/100
-
CORE-HIST-005/006 multi-turn history tests send three different messages with the same messageIdOpen
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
a2aproject/a2a-tck#248 ·