publishes([ __DIR__ . '/../config/prometheus.php' => config_path('prometheus.php'), ]); if (config('prometheus.metrics_route_enabled')) { $this->loadRoutesFrom(__DIR__ . '/routes.php'); } $exporter = $this->app->make(PrometheusExporter::class); /* @var PrometheusExporter $exporter */ foreach (config('prometheus.collectors') as $class) { $collector = $this->app->make($class); $exporter->registerCollector($collector); } } /** * Register bindings in the container. */ public function register() { $this->mergeConfigFrom(__DIR__ . '/../config/prometheus.php', 'prometheus'); $this->app->singleton(PrometheusExporter::class, function ($app) { $adapter = $app['prometheus.storage_adapter']; $prometheus = new CollectorRegistry($adapter); return new PrometheusExporter(config('prometheus.namespace'), $prometheus); }); $this->app->alias(PrometheusExporter::class, 'prometheus'); $this->app->bind('prometheus.storage_adapter_factory', function () { return new StorageAdapterFactory(); }); $this->app->bind(Adapter::class, function ($app) { $factory = $app['prometheus.storage_adapter_factory']; /** @var StorageAdapterFactory $factory */ $driver = config('prometheus.storage_adapter'); $configs = config('prometheus.storage_adapters'); $config = Arr::get($configs, $driver, []); return $factory->make($driver, $config); }); $this->app->alias(Adapter::class, 'prometheus.storage_adapter'); } /** * Get the services provided by the provider. * * @return array */ public function provides() { return [ 'prometheus', 'prometheus.storage_adapter_factory', 'prometheus.storage_adapter', ]; } }