1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace JildertMiedema\SystemMonitor; |
6
|
|
|
|
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use JildertMiedema\SystemMonitor\Console\MeasurementRun; |
9
|
|
|
use JildertMiedema\SystemMonitor\Measurements\MysqlConnectionSpeed; |
10
|
|
|
use JildertMiedema\SystemMonitor\Measurements\QueueSize; |
11
|
|
|
use JildertMiedema\SystemMonitor\Measurements\QueueWaitingTime; |
12
|
|
|
use JildertMiedema\SystemMonitor\Measurements\RedisConnectionSpeed; |
13
|
|
|
use JildertMiedema\SystemMonitor\Store\StatsdStore; |
14
|
|
|
|
15
|
|
|
final class SystemMonitorServiceProvider extends ServiceProvider |
16
|
|
|
{ |
17
|
|
|
public function register() |
18
|
|
|
{ |
19
|
|
|
$this->app->bind('measurement', function () { |
20
|
|
|
return new Manager($this->app); |
21
|
|
|
}); |
22
|
|
|
|
23
|
|
|
$this->app->bind('measurement.store', function () { |
24
|
|
|
return $this->app[StatsdStore::class]; |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
$this->app->resolving('measurement', function (Manager $manager) { |
28
|
|
|
$manager->extend($this->app[MysqlConnectionSpeed::class]); |
29
|
|
|
$manager->extend($this->app[RedisConnectionSpeed::class]); |
30
|
|
|
$manager->extend($this->app[QueueWaitingTime::class]); |
31
|
|
|
$manager->extend($this->app[QueueSize::class]); |
32
|
|
|
}); |
33
|
|
|
|
34
|
|
|
$this->app->singleton('command.measurement.run', function () { |
35
|
|
|
return new MeasurementRun(); |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
$this->commands('command.measurement.run'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Perform post-registration booting of services. |
43
|
|
|
*/ |
44
|
|
|
public function boot() |
45
|
|
|
{ |
46
|
|
|
$this->publishes([ |
47
|
|
|
$this->getConfigPath() => config_path('measurement.php'), |
48
|
|
|
], 'config'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
private function getConfigPath() |
52
|
|
|
{ |
53
|
|
|
return __DIR__.'/../../config/measurement.php'; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|