You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current documentation shows how to set the parent thread's X-ray entity in the worker thread:
defload_url(url, trace_entity):
# Set the parent X-Ray entity for the worker thread.xray_recorder.set_trace_entity(trace_entity)
# Subsegment captured from the following HTTP GET will be# a child of parent entity passed from the main thread.resp=requests.get(url)
# prevent thread pollutionxray_recorder.clear_trace_entities()
returnresp
However it's not clear how this interacts with capture/in_segment. For example, I assume this isn't correct, as the capture starts before we call set_trace_entity:
@xray_recorder.capture('subsegment_name')defload_url(url, trace_entity):
# Set the parent X-Ray entity for the worker thread.xray_recorder.set_trace_entity(trace_entity)
# Subsegment captured from the following HTTP GET will be# a child of parent entity passed from the main thread.resp=requests.get(url)
# prevent thread pollutionxray_recorder.clear_trace_entities()
returnresp
However, are these two OK?
defload_url(url, trace_entity):
# Set the parent X-Ray entity for the worker thread.xray_recorder.set_trace_entity(trace_entity)
withxray_recorder.capture('subsegment_name'):
# Subsegment captured from the following HTTP GET will be# a child of parent entity passed from the main thread.resp=requests.get(url)
# prevent thread pollutionxray_recorder.clear_trace_entities()
returnresp
defload_url(url, trace_entity):
# Set the parent X-Ray entity for the worker thread.xray_recorder.set_trace_entity(trace_entity)
withxray_recorder.in_segment('segment_name') assegment:
segment.put_metadata('key', dict, 'namespace')
# Subsegment captured from the following HTTP GET will be# a child of parent entity passed from the main thread.resp=requests.get(url)
# prevent thread pollutionxray_recorder.clear_trace_entities()
returnresp
It would be great if the docs on threading had a more complete example.
The text was updated successfully, but these errors were encountered:
I'm not the most familiar with this X-Ray Python SDK, but I'll try to answer your question.
Based on what I see, both your solutions make sense and to as far as I can tell they should work. Your example of something that doesn't work also makes sense to me. Have you tried it in the X-Ray console and do you notice it doesn't work? If that's the case please include screenshots of what you see versus what you expect!
The current documentation shows how to set the parent thread's X-ray entity in the worker thread:
However it's not clear how this interacts with
capture
/in_segment
. For example, I assume this isn't correct, as the capture starts before we callset_trace_entity
:However, are these two OK?
It would be great if the docs on threading had a more complete example.
The text was updated successfully, but these errors were encountered: