To create a sub-segment aws-xray requires that a valid segment is opened. By default remote lambda execution opens a segment for you and you just have to add a subsegment but while running locally we need to open segment manually before adding sub-segment.
I can put things in try-except block to initiate subsegments only when segments are available but is there any method that checks if segment is open.
Right now working with this:
try:
xray_recorder.current_segment()
except:
xray_recorder.begin_segment(self.segment_name)