From 26caf16d93daee62715a29044de09c85fd16557d Mon Sep 17 00:00:00 2001 From: Jonas De Smet Date: Thu, 26 Nov 2020 22:34:09 +0100 Subject: [PATCH] Option to set custom snapshot locking time This way you can schedule snapshots every minute, every two minutes and set the locking time the same so they can be stored and shown in the horizon dashboard. --- config/horizon.php | 6 ++++-- src/Console/SnapshotCommand.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/config/horizon.php b/config/horizon.php index 0e36957b..f17efe4f 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -113,8 +113,9 @@ |-------------------------------------------------------------------------- | | Here you can configure how many snapshots should be kept to display in - | the metrics graph. This will get used in combination with Horizon's - | `horizon:snapshot` schedule to define how long to retain metrics. + | the metrics graph and how often they can be stored. + | This will get used in combination with Horizon's `horizon:snapshot` + | schedule to define how long to retain metrics. | */ @@ -123,6 +124,7 @@ 'job' => 24, 'queue' => 24, ], + 'snapshot_lock' => 300, ], /* diff --git a/src/Console/SnapshotCommand.php b/src/Console/SnapshotCommand.php index 72c642b6..50b46342 100644 --- a/src/Console/SnapshotCommand.php +++ b/src/Console/SnapshotCommand.php @@ -31,7 +31,7 @@ class SnapshotCommand extends Command */ public function handle(Lock $lock, MetricsRepository $metrics) { - if ($lock->get('metrics:snapshot', 300)) { + if ($lock->get('metrics:snapshot', config('horizon.metrics.snapshot_lock', 300))) { $metrics->snapshot(); $this->info('Metrics snapshot stored successfully.');