generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af9307f
commit 06336dd
Showing
10 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Spatie\Prometheus\Collectors\Horizon; | ||
|
||
use Laravel\Horizon\Contracts\MetricsRepository; | ||
use Spatie\Prometheus\Collectors\Collector; | ||
use Spatie\Prometheus\Facades\Prometheus; | ||
|
||
class JobsPerMinuteCollector implements Collector | ||
{ | ||
public function register(): void | ||
{ | ||
Prometheus::addGauge('jobs per minute') | ||
->helpText('The number of jobs per minute') | ||
->value(fn() => app(MetricsRepository::class)->jobsProcessedPerMinute()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Spatie\Prometheus\Collectors\Horizon; | ||
|
||
use Laravel\Horizon\Contracts\JobRepository; | ||
use Spatie\Prometheus\Collectors\Collector; | ||
use Spatie\Prometheus\Facades\Prometheus; | ||
|
||
class RecentJobsCollector implements Collector | ||
{ | ||
public function register(): void | ||
{ | ||
Prometheus::addGauge('Recent jobs') | ||
->helpText('The number of recent jobs') | ||
->value(fn() => app(JobRepository::class)->countRecent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Spatie\Prometheus\Collectors\Horizon\HorizonStatusCollector; | ||
|
||
it('can register the horizon status collector', function () { | ||
app(HorizonStatusCollector::class)->register(); | ||
|
||
assertPrometheusResultsMatchesSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Spatie\Prometheus\Collectors\Horizon\JobsPerMinuteCollector; | ||
|
||
it('can register the jobs per minute collector', function () { | ||
app(JobsPerMinuteCollector::class)->register(); | ||
|
||
assertPrometheusResultsMatchesSnapshot(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
use Spatie\Prometheus\Collectors\Horizon\RecentJobsCollector; | ||
|
||
it('can register the recent jobs collector', function () { | ||
app(RecentJobsCollector::class)->register(); | ||
|
||
assertPrometheusResultsMatchesSnapshot(); | ||
}); |
6 changes: 6 additions & 0 deletions
6
...apshots__/HorizonStatusCollectorTest__it_can_register_the_horizon_status_collector__1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# HELP app_horizon_status The status of Horizon, -1 = inactive, 0 = paused, 1 = running | ||
# TYPE app_horizon_status gauge | ||
app_horizon_status -1 | ||
# HELP php_info Information about the PHP environment. | ||
# TYPE php_info gauge | ||
php_info{version="8.2.0"} 1 |
6 changes: 6 additions & 0 deletions
6
...pshots__/JobsPerMinuteCollectorTest__it_can_register_the_jobs_per_minute_collector__1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# HELP app_jobs_per_minute The number of jobs per minute | ||
# TYPE app_jobs_per_minute gauge | ||
app_jobs_per_minute 0 | ||
# HELP php_info Information about the PHP environment. | ||
# TYPE php_info gauge | ||
php_info{version="8.2.0"} 1 |
6 changes: 6 additions & 0 deletions
6
...s/__snapshots__/RecentJobsCollectorTest__it_can_register_the_recent_jobs_collector__1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# HELP app_recent_jobs The number of recent jobs | ||
# TYPE app_recent_jobs gauge | ||
app_recent_jobs 0 | ||
# HELP php_info Information about the PHP environment. | ||
# TYPE php_info gauge | ||
php_info{version="8.2.0"} 1 |