This commit is contained in:
Daniil Zobov 2020-04-14 16:28:44 +03:00
parent 4b056b8c1e
commit eff4294d5a
4 changed files with 37 additions and 32 deletions

View file

@ -23,7 +23,7 @@ Register the service provider in app.php
```php
'providers' => [
// ...
Superbalist\LaravelPrometheusExporter\LaravelServiceProvider::class,
Superbalist\LaravelPrometheusExporter\PrometheusServiceProvider::class,
]
```
@ -37,7 +37,7 @@ Register the facade in app.php
#### Lumen
```php
$app->register(Superbalist\LaravelPrometheusExporter\LumenServiceProvider::class);
$app->register(Superbalist\LaravelPrometheusExporter\LumenPrometheusServiceProvider::class);
```
## Configuration

View file

@ -1,26 +0,0 @@
<?php
namespace Superbalist\LaravelPrometheusExporter;
class LaravelServiceProvider extends PrometheusServiceProvider
{
/**
* Perform post-registration booting of services.
*/
public function boot()
{
$this->publishes([
__DIR__ . '/../config/prometheus.php' => config_path('prometheus.php'),
]);
parent::boot();
}
/**
* Load routes.
*/
protected function loadRoutes()
{
$this->loadRoutesFrom(__DIR__ . '/laravel_routes.php');
}
}

View file

@ -2,8 +2,16 @@
namespace Superbalist\LaravelPrometheusExporter;
class LumenServiceProvider extends PrometheusServiceProvider
class LumenPrometheusServiceProvider extends PrometheusServiceProvider
{
/**
* Publish files.
*/
protected function publishFiles()
{
// do nothing
}
/**
* Load routes.
*/

View file

@ -7,14 +7,16 @@ use Illuminate\Support\ServiceProvider;
use Prometheus\CollectorRegistry;
use Prometheus\Storage\Adapter;
abstract class PrometheusServiceProvider extends ServiceProvider
class PrometheusServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*/
public function boot()
{
$this->mergeConfigFrom(__DIR__ . '/../config/prometheus.php', 'prometheus');
$this->publishFiles();
$this->mergeConfigs();
$this->loadRoutes();
if (config('prometheus.metrics_route_enabled')) {
$this->loadRoutes();
@ -27,10 +29,31 @@ abstract class PrometheusServiceProvider extends ServiceProvider
}
}
/**
* Merge configs.
*/
protected function mergeConfigs()
{
$this->mergeConfigFrom(__DIR__ . '/../config/prometheus.php', 'prometheus');
}
/**
* Publish files.
*/
protected function publishFiles()
{
$this->publishes([
__DIR__ . '/../config/prometheus.php' => config_path('prometheus.php'),
]);
}
/**
* Load routes.
*/
abstract protected function loadRoutes();
protected function loadRoutes()
{
$this->loadRoutesFrom(__DIR__ . '/laravel_routes.php');
}
/**
* Register bindings in the container.