1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
namespace Hhxsv5\LaravelS\Components\Prometheus; |
4
|
|
|
|
5
|
|
|
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\HttpRequestCollector; |
6
|
|
|
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\SwooleProcessCollector; |
7
|
|
|
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\SwooleStatsCollector; |
8
|
|
|
use Hhxsv5\LaravelS\Components\Prometheus\Collectors\SystemCollector; |
9
|
|
|
use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
|
|
|
|
10
|
|
|
|
11
|
|
|
class ServiceProvider extends BaseServiceProvider |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
protected $defer = true; |
14
|
|
|
|
15
|
|
|
public function boot() |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
$this->publishes([ |
|
|
|
|
18
|
|
|
__DIR__ . '/../../../config/prometheus.php' => base_path('config/prometheus.php'), |
|
|
|
|
19
|
|
|
]); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function register() |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
$this->mergeConfigFrom( |
25
|
|
|
__DIR__ . '/../../../config/prometheus.php', 'prometheus' |
26
|
|
|
); |
27
|
|
|
$this->app->singleton(RequestMiddleware::class, function ($app) { |
|
|
|
|
28
|
|
|
return new RequestMiddleware($app->make(HttpRequestCollector::class)); |
29
|
|
|
}); |
|
|
|
|
30
|
|
|
$this->app->singleton(HttpRequestCollector::class, function ($app) { |
|
|
|
|
31
|
|
|
return new HttpRequestCollector($app['config']->get('prometheus')); |
32
|
|
|
}); |
|
|
|
|
33
|
|
|
$this->app->singleton(SwooleProcessCollector::class, function ($app) { |
|
|
|
|
34
|
|
|
return new SwooleProcessCollector($app['config']->get('prometheus')); |
35
|
|
|
}); |
|
|
|
|
36
|
|
|
$this->app->singleton(SwooleStatsCollector::class, function ($app) { |
|
|
|
|
37
|
|
|
return new SwooleStatsCollector($app['config']->get('prometheus')); |
38
|
|
|
}); |
|
|
|
|
39
|
|
|
$this->app->singleton(SystemCollector::class, function ($app) { |
|
|
|
|
40
|
|
|
return new SystemCollector($app['config']->get('prometheus')); |
41
|
|
|
}); |
|
|
|
|
42
|
|
|
$this->app->singleton(Exporter::class, function ($app) { |
|
|
|
|
43
|
|
|
return new Exporter($app['config']->get('prometheus')); |
44
|
|
|
}); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function provides() |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
return [ |
50
|
|
|
RequestMiddleware::class, |
51
|
|
|
HttpRequestCollector::class, |
52
|
|
|
SwooleProcessCollector::class, |
53
|
|
|
SwooleStatsCollector::class, |
54
|
|
|
SystemCollector::class, |
55
|
|
|
Exporter::class, |
56
|
|
|
]; |
57
|
|
|
} |
58
|
|
|
} |