def test_get_realert_every(self): with mock.patch( 'paasta_tools.monitoring_tools.__get_monitoring_config_value', ) as get_monitoring_config_value_patch: monitoring_tools.get_realert_every(self.overrides, self.service, self.soa_dir) get_monitoring_config_value_patch.assert_called_once_with('realert_every', self.overrides, self.service, self.soa_dir)
def compose_monitoring_overrides_for_service(chronos_job_config): """ Compose a group of monitoring overrides """ monitoring_overrides = chronos_job_config.get_monitoring() if 'alert_after' not in monitoring_overrides: monitoring_overrides['alert_after'] = '15m' monitoring_overrides['check_every'] = '1m' monitoring_overrides['runbook'] = monitoring_tools.get_runbook( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, ) if 'realert_every' not in monitoring_overrides: guessed_realert_every = guess_realert_every(chronos_job_config) if guessed_realert_every is not None: monitoring_overrides[ 'realert_every'] = monitoring_tools.get_realert_every( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, monitoring_defaults=lambda x: {'realert_every': guessed_realert_every}.get(x), ) else: monitoring_overrides[ 'realert_every'] = monitoring_tools.get_realert_every( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, ) return monitoring_overrides
def compose_monitoring_overrides_for_service(chronos_job_config): """ Compose a group of monitoring overrides """ monitoring_overrides = chronos_job_config.get_monitoring() if "alert_after" not in monitoring_overrides: monitoring_overrides["alert_after"] = "15m" monitoring_overrides["check_every"] = "1m" monitoring_overrides["runbook"] = monitoring_tools.get_runbook( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, ) if "realert_every" not in monitoring_overrides: guessed_realert_every = guess_realert_every(chronos_job_config) if guessed_realert_every is not None: monitoring_overrides[ "realert_every"] = monitoring_tools.get_realert_every( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, monitoring_defaults=lambda x: {"realert_every": guessed_realert_every}.get(x), ) else: monitoring_overrides[ "realert_every"] = monitoring_tools.get_realert_every( monitoring_overrides, chronos_job_config.service, soa_dir=chronos_job_config.soa_dir, ) return monitoring_overrides
def test_get_realert_every(self): with mock.patch( 'paasta_tools.monitoring_tools.__get_monitoring_config_value', autospec=True ) as get_monitoring_config_value_patch: monitoring_defaults = mock.Mock() monitoring_tools.get_realert_every(self.overrides, self.service, self.soa_dir, monitoring_defaults) get_monitoring_config_value_patch.assert_called_once_with('realert_every', self.overrides, self.service, self.soa_dir, monitoring_defaults)
def compose_monitoring_overrides_for_service(chronos_job_config, soa_dir): """ Compose a group of monitoring overrides """ monitoring_overrides = chronos_job_config.get_monitoring() if 'alert_after' not in monitoring_overrides: monitoring_overrides['alert_after'] = '2m' monitoring_overrides['check_every'] = '1m' monitoring_overrides['runbook'] = monitoring_tools.get_runbook( monitoring_overrides, chronos_job_config.service, soa_dir=soa_dir) monitoring_overrides['realert_every'] = monitoring_tools.get_realert_every( monitoring_overrides, chronos_job_config.service, soa_dir=soa_dir) return monitoring_overrides