Skip to content

Commit

Permalink
[ENG-619] Base health checks on time instead of quantity.
Browse files Browse the repository at this point in the history
This is way saver, and about 1000x faster.
Only checks kickoff events and scheduled events, but well worth the
change.
  • Loading branch information
heathdutton committed Feb 18, 2019
1 parent b5a8614 commit f22e280
Show file tree
Hide file tree
Showing 5 changed files with 277 additions and 69 deletions.
66 changes: 45 additions & 21 deletions Command/HealthCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ protected function configure()
{
$this->setName('mautic:health:check')
->setDescription('General all purpose health check.')
// ->addOption(
// 'campaign-rebuild-delay',
// null,
// InputOption::VALUE_OPTIONAL,
// 'The maximum number of contacts waiting to be ingested into a campaign from a segment.'
// )
->addOption(
'campaign-rebuild-threshold',
'campaign-kickoff-delay',
null,
InputOption::VALUE_OPTIONAL,
'The maximum number of contacts waiting to be ingested into a campaign from a segment.'
'The maximum number of seconds average allowed for kickoff events at the top of the campaign.'
)
->addOption(
'campaign-trigger-threshold',
'campaign-scheduled-delay',
null,
InputOption::VALUE_OPTIONAL,
'The maximum number of contacts waiting for scheduled campaign events to fire which are late.'
'The maximum number of seconds average allowed for scheduled events (beyond the intended delays).'
)
->addOption(
'campaign-inactive-delay',
null,
InputOption::VALUE_OPTIONAL,
'The maximum number of seconds average allowed for inactive events (the red non-action paths).'
);

parent::configure();
Expand All @@ -55,12 +67,14 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$verbose = $input->getOption('verbose');
$campaignRebuildThreshold = $input->getOption('campaign-rebuild-threshold');
$campaignTriggerThreshold = $input->getOption('campaign-trigger-threshold');
$quiet = $input->getOption('quiet');
$container = $this->getContainer();
$translator = $container->get('translator');
$verbose = $input->getOption('verbose');
// $campaignRebuildDelay = $input->getOption('campaign-rebuild-delay');
$campaignKickoffDelay = $input->getOption('campaign-kickoff-delay');
$campaignScheduledDelay = $input->getOption('campaign-scheduled-delay');
$campaignInactiveDelay = $input->getOption('campaign-inactive-delay');
$quiet = $input->getOption('quiet');
$container = $this->getContainer();
$translator = $container->get('translator');

if (!$this->checkRunStatus($input, $output)) {
return 0;
Expand All @@ -69,24 +83,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
/** @var HealthModel $healthModel */
$healthModel = $container->get('mautic.health.model.health');
if ($verbose) {
$output->writeln(
'<info>'.$translator->trans(
'mautic.health.running'
).'</info>'
);
$output->writeln('<info>'.$translator->trans('mautic.health.running').'</info>');
}
$settings = [];
if ($campaignRebuildThreshold) {
$settings['campaign_rebuild_threshold'] = $campaignRebuildThreshold;
// if ($campaignRebuildDelay) {
// $settings['campaign_rebuild_delay'] = $campaignRebuildDelay;
// }
if ($campaignKickoffDelay) {
$settings['campaign_kickoff_delay'] = $campaignKickoffDelay;
}
if ($campaignScheduledDelay) {
$settings['campaign_scheduled_delay'] = $campaignScheduledDelay;
}
if ($campaignTriggerThreshold) {
$settings['campaign_trigger_threshold'] = $campaignTriggerThreshold;
if ($campaignInactiveDelay) {
$settings['campaign_inactive_delay'] = $campaignInactiveDelay;
}
if ($settings) {
$healthModel->setSettings($settings);
}
$healthModel->campaignRebuildCheck($output, $verbose);
$healthModel->campaignTriggerCheck($output, $verbose);
if ($verbose) {
$output->writeln('<info>'.$translator->trans('mautic.health.kickoff').'</info>');
}
$healthModel->campaignKickoffCheck($output, $verbose);
if ($verbose) {
$output->writeln('<info>'.$translator->trans('mautic.health.scheduled').'</info>');
}
$healthModel->campaignScheduledCheck($output, $verbose);
// @todo - Add negative action path check.
// $healthModel->campaignRebuildCheck($output, $verbose);
if (!$quiet) {
$healthModel->reportIncidents($output);
}
Expand Down
2 changes: 2 additions & 0 deletions Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'arguments' => [
'doctrine.orm.entity_manager',
'mautic.helper.integration',
'mautic.campaign.model.campaign',
'mautic.campaign.model.event',
],
],
],
Expand Down
38 changes: 30 additions & 8 deletions Integration/HealthIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,25 +368,47 @@ public function getRequiredKeyFields()
public function appendToForm(&$builder, $data, $formArea)
{
if ('features' == $formArea) {
// $builder->add(
// 'campaign_rebuild_delay',
// 'number',
// [
// 'label' => $this->translator->trans('mautic.health.campaign_rebuild_delay'),
// 'data' => !isset($data['campaign_rebuild_delay']) ? 10000 : $data['campaign_rebuild_delay'],
// 'attr' => [
// 'tooltip' => $this->translator->trans('mautic.health.campaign_rebuild_delay.tooltip'),
// ],
// ]
// );
$builder->add(
'campaign_rebuild_threshold',
'campaign_kickoff_delay',
'number',
[
'label' => $this->translator->trans('mautic.health.campaign_rebuild_threshold'),
'data' => !isset($data['campaign_rebuild_threshold']) ? 10000 : $data['campaign_rebuild_threshold'],
'label' => $this->translator->trans('mautic.health.campaign_kickoff_delay'),
'data' => !isset($data['campaign_kickoff_delay']) ? 3600 : $data['campaign_kickoff_delay'],
'attr' => [
'tooltip' => $this->translator->trans('mautic.health.campaign_rebuild_threshold.tooltip'),
'tooltip' => $this->translator->trans('mautic.health.campaign_kickoff_delay.tooltip'),
],
]
);
$builder->add(
'campaign_trigger_threshold',
'campaign_scheduled_delay',
'number',
[
'label' => $this->translator->trans('mautic.health.campaign_trigger_threshold'),
'data' => !isset($data['campaign_trigger_threshold']) ? 1000 : $data['campaign_trigger_threshold'],
'label' => $this->translator->trans('mautic.health.campaign_scheduled_delay'),
'data' => !isset($data['campaign_scheduled_delay']) ? 3600 : $data['campaign_scheduled_delay'],
'attr' => [
'tooltip' => $this->translator->trans('mautic.health.campaign_trigger_threshold.tooltip'),
'tooltip' => $this->translator->trans('mautic.health.campaign_scheduled_delay.tooltip'),
],
]
);
$builder->add(
'campaign_inactive_delay',
'number',
[
'label' => $this->translator->trans('mautic.health.campaign_inactive_delay'),
'data' => !isset($data['campaign_inactive_delay']) ? 3600 : $data['campaign_inactive_delay'],
'attr' => [
'tooltip' => $this->translator->trans('mautic.health.campaign_inactive_delay.tooltip'),
],
]
);
Expand Down
Loading

0 comments on commit f22e280

Please sign in to comment.