in aws_xray_sdk/core/lambda_launcher.py [0:0]
def put_subsegment(self, subsegment):
"""
Refresh the segment every time this function is invoked to prevent
a new subsegment from being attached to a leaked segment/subsegment.
"""
current_entity = self.get_trace_entity()
if not self._is_subsegment(current_entity) and (getattr(current_entity, 'initializing', None) or isinstance(current_entity, DummySegment)):
if global_sdk_config.sdk_enabled() and not os.getenv(LAMBDA_TRACE_HEADER_KEY):
log.warning("Subsegment %s discarded due to Lambda worker still initializing" % subsegment.name)
return
current_entity.add_subsegment(subsegment)
self._local.entities.append(subsegment)