def should_trace(self, sampling_req=None):
        """
        Return the matched sampling rule name if the sampler finds one
        and decide to sample. If no sampling rule matched, it falls back
        to the local sampler's ``should_trace`` implementation.
        All optional arguments are extracted from incoming requests by
        X-Ray middleware to perform path based sampling.
        """
        if not global_sdk_config.sdk_enabled():
            return False

        if not self._started:
            self.start() # only front-end that actually uses the sampler spawns poller threads

        now = int(time.time())
        if sampling_req and not sampling_req.get('service_type', None):
            sampling_req['service_type'] = self._origin
        elif sampling_req is None:
            sampling_req = {'service_type': self._origin}
        matched_rule = self._cache.get_matched_rule(sampling_req, now)
        if matched_rule:
            log.debug('Rule %s is selected to make a sampling decision.', matched_rule.name)
            return self._process_matched_rule(matched_rule, now)
        else:
            log.info('No effective centralized sampling rule match. Fallback to local rules.')
            return self._local_sampler.should_trace(sampling_req)
def should_trace ( self , sampling_req = None ) : if not global_sdk_config . sdk_enabled ( ) : return False if not self . _started : self . start ( ) now = int ( time . time ( ) ) if sampling_req and not sampling_req . get ( 'service_type' , None ) : sampling_req [ 'service_type' ] = self . _origin elif sampling_req is None : sampling_req = { 'service_type' : self . _origin } matched_rule = self . _cache . get_matched_rule ( sampling_req , now ) if matched_rule : log . debug ( 'Rule %s is selected to make a sampling decision.' , matched_rule . name ) return self . _process_matched_rule ( matched_rule , now ) else : log . info ( 'No effective centralized sampling rule match. Fallback to local rules.' ) return self . _local_sampler . should_trace ( sampling_req )
Return the matched sampling rule name if the sampler finds one
        and decide to sample. If no sampling rule matched, it falls back
        to the local sampler's ``should_trace`` implementation.
        All optional arguments are extracted from incoming requests by
        X-Ray middleware to perform path based sampling.