def _harvest_default(self): shutdown = self._harvest_shutdown.isSet() if shutdown: _logger.debug('Commencing default harvest of application data and ' 'forcing a shutdown at the same time.') else: self._scheduler.enter(60.0, 2, self._harvest_default, ()) _logger.debug('Commencing default harvest of application data.') self._default_harvest_count += 1 self._last_default_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown, flexible=False) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._default_harvest_duration = \ time.time() - self._last_default_harvest _logger.debug( 'Completed default harvest of application data in %.2f ' 'seconds.', self._default_harvest_duration)
def _harvest_default(self, shutdown=False): if not self._harvest_shutdown.isSet(): self._scheduler.enter(60.0, 2, self._harvest_default, ()) _logger.debug('Commencing harvest[default] of application data.') elif not shutdown: return else: _logger.debug( 'Commencing final harvest[default] of application data.') self._default_harvest_count += 1 self._last_default_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown, flexible=False) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._default_harvest_duration = \ time.time() - self._last_default_harvest _logger.debug( 'Completed harvest[default] of application data in %.2f ' 'seconds.', self._default_harvest_duration)
def _harvest_flexible(self): if not self._harvest_shutdown.isSet(): event_harvest_config = self.global_settings().event_harvest_config self._scheduler.enter( event_harvest_config.report_period_ms / 1000.0, 1, self._harvest_flexible, ()) _logger.debug('Commencing flexible harvest of application data.') self._flexible_harvest_count += 1 self._last_flexible_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown=False, flexible=True) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._flexible_harvest_duration = \ time.time() - self._last_flexible_harvest _logger.debug( 'Completed flexible harvest of application data in %.2f ' 'seconds.', self._flexible_harvest_duration)
def _run_harvest(self, shutdown=False): # This isn't going to maintain order of applications # such that oldest is always done first. A new one could # come in earlier once added and upset the overall # timing. The data collector should cope with this # though. if shutdown: _logger.debug('Commencing harvest of all application data and ' 'forcing a shutdown at the same time.') else: _logger.debug('Commencing harvest of all application data.') self._harvest_count += 1 self._last_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._harvest_duration = time.time() - self._last_harvest _logger.debug('Completed harvest of all application data in %.2f ' 'seconds.', self._harvest_duration)
def _run_harvest(self, shutdown=False): # This isn't going to maintain order of applications # such that oldest is always done first. A new one could # come in earlier once added and upset the overall # timing. The data collector should cope with this # though. if shutdown: _logger.debug('Commencing harvest of all application data and ' 'forcing a shutdown at the same time.') else: _logger.debug('Commencing harvest of all application data.') self._harvest_count += 1 self._last_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._harvest_duration = time.time() - self._last_harvest _logger.debug( 'Completed harvest of all application data in %.2f ' 'seconds.', self._harvest_duration)
def _harvest_flexible(self, shutdown=False): # TODO 弹性收集Application数据 if not self._harvest_shutdown.isSet( ): # TODO 如果线程阻塞,再将收集任务放进调度任务器里,这是一个递归调用的过程,一直等待阻塞结束 event_harvest_config = self.global_settings().event_harvest_config self._scheduler.enter( event_harvest_config.report_period_ms / 1000.0, 1, self._harvest_flexible, ()) _logger.debug('Commencing flexible harvest of application data.') elif not shutdown: return else: _logger.debug( 'Commencing final flexible harvest of application data.') self._flexible_harvest_count += 1 self._last_flexible_harvest = time.time() for application in list(six.itervalues( self._applications)): # TODO 为每个应用收集数据 try: application.harvest(shutdown=False, flexible=True) except Exception: _logger.exception('Failed to harvest data ' 'for %s.' % application.name) self._flexible_harvest_duration = \ time.time() - self._last_flexible_harvest _logger.debug( 'Completed flexible harvest of application data in %.2f ' 'seconds.', self._flexible_harvest_duration)
def _harvest_flexible(self, shutdown=False): if not self._harvest_shutdown_is_set(): event_harvest_config = self.global_settings().event_harvest_config self._scheduler.enter( event_harvest_config.report_period_ms / 1000.0, 1, self._harvest_flexible, ()) _logger.debug("Commencing harvest[flexible] of application data.") elif not shutdown: return else: _logger.debug( "Commencing final harvest[flexible] of application data.") self._flexible_harvest_count += 1 self._last_flexible_harvest = time.time() for application in list(six.itervalues(self._applications)): try: application.harvest(shutdown=False, flexible=True) except Exception: _logger.exception("Failed to harvest data for %s." % application.name) self._flexible_harvest_duration = time.time( ) - self._last_flexible_harvest _logger.debug( "Completed harvest[flexible] of application data in %.2f seconds.", self._flexible_harvest_duration)
def record_transaction(self, app_name, data, profile_samples=None): """Processes the raw transaction data, generating and recording appropriate metrics against the named application. If there has been no prior request to activate the application, the metric is discarded. """ application = self._applications.get(app_name, None) if application is None or not application.active: return application.record_transaction(data, profile_samples) if self._config.serverless_mode.enabled: application.harvest()