Skip to content

Commit

Permalink
Option to set custom snapshot locking time
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glamorous committed Nov 26, 2020
1 parent cb4e564 commit 26caf16
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions config/horizon.php
Expand Up @@ -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.
|
*/

Expand All @@ -123,6 +124,7 @@
'job' => 24,
'queue' => 24,
],
'snapshot_lock' => 300,
],

/*
Expand Down
2 changes: 1 addition & 1 deletion src/Console/SnapshotCommand.php
Expand Up @@ -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.');
Expand Down

0 comments on commit 26caf16

Please sign in to comment.