Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.x] Add metrics options and dark mode config #795

Merged
merged 5 commits into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions config/horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,38 @@
'monitored' => 10080,
],

/*
|--------------------------------------------------------------------------
| Metrics
|--------------------------------------------------------------------------
|
| Here you can configure how many snapshots should be kept to display in
| the metrics graph. You should use this in conjunction with the
| `horizon:snapshot` schedule to define how long of a timespan
| you want to see in the metrics.
|
*/

'metrics' => [
'trim_snapshots' => [
'job' => 24,
'queue' => 24,
],
],

/*
|--------------------------------------------------------------------------
| Theme
|--------------------------------------------------------------------------
|
| Here you can define which theme Horizon should load.
|
| Supported: "light", "dark"
|
*/

'theme' => 'light',

/*
|--------------------------------------------------------------------------
| Fast Termination
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/LineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@

<template>
<div style="position: relative;">
<canvas ref="canvas" height="70"></canvas>
<canvas ref="canvas" height="120"></canvas>
</div>
</template>
11 changes: 6 additions & 5 deletions resources/js/screens/metrics/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
prepareData(data) {
return _.chain(data)
.map(value => {
value.time = this.formatDate(value.time).format("hh:mmA");
value.time = this.formatDate(value.time).format("MMM-D hh:mmA");

return value;
})
Expand Down Expand Up @@ -86,10 +86,11 @@
label: label,
data: _.map(data, attribute),
lineTension: 0,
backgroundColor: 'rgba(235, 243, 249, 0.4)',
pointBackgroundColor: '#3981B4',
borderColor: '#3981B4',
borderWidth: 4,
backgroundColor: 'transparent',
pointBackgroundColor: '#fff',
pointBorderColor: '#7746ec',
borderColor: '#7746ec',
borderWidth: 2,
},
],
};
Expand Down
10 changes: 8 additions & 2 deletions src/Horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class Horizon
'Metrics', 'Locks', 'Processes',
];

public function __construct()
{
static::$useDarkTheme = config('horizon.theme') === 'dark';
}

/**
* Determine if the given request can access the Horizon dashboard.
*
Expand Down Expand Up @@ -110,11 +115,12 @@ public static function use($connection)
/**
* Specifies that Horizon should use the dark theme.
*
* @param bool $on
* @return static
*/
public static function night()
public static function night($on = true)
{
static::$useDarkTheme = true;
static::$useDarkTheme = $on;

return new static;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Repositories/RedisMetricsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ protected function storeSnapshotForJob($job)
);

$this->connection()->zremrangebyrank(
'snapshot:'.$key, 0, -25
'snapshot:'.$key, 0, -abs(1 + config('horizon.metrics.trim_snapshots.job', 24))
);
}

Expand All @@ -298,7 +298,7 @@ protected function storeSnapshotForQueue($queue)
);

$this->connection()->zremrangebyrank(
'snapshot:'.$key, 0, -25
'snapshot:'.$key, 0, -abs(1 + config('horizon.metrics.trim_snapshots.queue', 24))
);
}

Expand Down