def _begin_subsegment_helper()

in aws_xray_sdk/core/recorder.py [0:0]


    def _begin_subsegment_helper(self, name, namespace='local', beginWithoutSampling=False):
        '''
        Helper method to begin_subsegment and begin_subsegment_without_sampling
        '''
        # Generating the parent dummy segment is necessary.
        # We don't need to store anything in context. Assumption here
        # is that we only work with recorder-level APIs.
        if not global_sdk_config.sdk_enabled():
            return DummySubsegment(DummySegment(global_sdk_config.DISABLED_ENTITY_NAME))

        segment = self.current_segment()
        if not segment:
            log.warning("No segment found, cannot begin subsegment %s." % name)
            return None

        current_entity = self.get_trace_entity()
        if not current_entity.sampled or beginWithoutSampling:
            subsegment = DummySubsegment(segment, name)
        else:
            subsegment = Subsegment(name, namespace, segment)

        self.context.put_subsegment(subsegment)
        return subsegment