Exemplo n.º 1
0
    def _poll_profiler_service(self):
        """Polls the profiler server stoplessly."""
        logger.debug('Profiler has started')
        build_service_backoff = backoff.Backoff()
        while self._profiler_service is None:
            try:
                self._profiler_service = self._build_service()
            except BaseException as e:  # pylint: disable=broad-except
                # Exponential backoff.
                backoff_duration = build_service_backoff.next_backoff()
                logger.error(
                    'Failed to build the Discovery client for profiler '
                    '(will retry after %.3fs): %s', backoff_duration, str(e))
                time.sleep(backoff_duration)

        while True:
            profile = None
            while not profile:
                try:
                    logger.debug('Starting to create profile')
                    profile = self._create_profile()
                    self._backoff = backoff.Backoff()
                    logger.debug('Successfully created a %s profile',
                                 profile['profileType'])
                except BaseException as e:
                    # Uses the server specified backoff duration if it is present in the
                    # error message, otherwise uses exponential backoff.
                    backoff_duration = self._backoff.next_backoff(e)
                    logger.error(
                        'Failed to create profile (will retry after %.3fs): %s',
                        backoff_duration, str(e))
                    time.sleep(backoff_duration)

            self._collect_and_upload_profile(profile)
Exemplo n.º 2
0
 def __init__(self):
     self._backoff = backoff.Backoff()
     self._filter_log()
     self._started = False
     self._profiler_service = None
Exemplo n.º 3
0
 def __init__(self):
   self._backoff = backoff.Backoff()
   self._filter_log()
   self._started = False