Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
"php": "^8.1",
"ext-redis": "*",
"laravel/framework": "^9.0 || ^10.0 || ^11.0",
"laravel/octane": "^2.0",
"promphp/prometheus_client_php": "^2.6"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2",
"nunomaduro/collision": "^6.0 || ^7.0 || ^8.1",
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
"pestphp/pest": "^1.22 || ^2.0",
"pestphp/pest-plugin-laravel": "^1.1 || ^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.11",
"spaze/phpstan-disallowed-calls": "^2.15",
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0"
"swoole/ide-helper": "~5.0.0"
},
"autoload": {
"psr-4": {
Expand Down
54 changes: 54 additions & 0 deletions config/octane.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Octane Swoole Tables
|--------------------------------------------------------------------------
|
| While using Swoole, you may define additional tables as required by the
| application. These tables can be used to store data that needs to be
| quickly accessed by other workers on the particular Swoole server.
|
*/

'tables' => [
'gauges:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'gauge_values:10000' => [
'value' => 'float',
'key' => 'string:10000',
],

'сounters:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'сounter_values:10000' => [
'value' => 'float',
'key' => 'string:10000',
],

'summaries:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'summary_values:10000' => [
'key' => 'string:10000',
'sampleTimes' => 'string:10000',
'sampleValues' => 'string:10000',
],

'histograms:1000' => [
'meta' => 'string:10000',
'valueKeys' => 'string:10000',
],
'histogram_values:10000' => [
'value' => 'float',
'key' => 'string:10000',
],
],
];
3 changes: 3 additions & 0 deletions config/prometheus.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
// or
// 'apcu' => [
// 'prefix' => 'metrics'
// ],
// or
// 'octane-cache' => [
// ],
'label_middlewares' => [
// \Ensi\LaravelPrometheus\LabelMiddlewares\AppNameLabelMiddleware::class,
Expand Down
3 changes: 3 additions & 0 deletions src/MetricsBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Ensi\LaravelPrometheus\Metrics\Summary;
use Ensi\LaravelPrometheus\OnDemandMetrics\OnDemandMetric;
use Ensi\LaravelPrometheus\Storage\NullStorage;
use Ensi\LaravelPrometheus\Storage\OctaneCache;
use Ensi\LaravelPrometheus\Storage\Redis;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis as RedisManager;
Expand Down Expand Up @@ -179,6 +180,8 @@ private function getStorage(): Adapter
return new APCng($this->config['apcu-ng']['prefix']);
case array_key_exists('memory', $this->config):
return new InMemory();
case array_key_exists('octane-cache', $this->config):
return new OctaneCache();
case array_key_exists('null-storage', $this->config):
return new NullStorage();
}
Expand Down
3 changes: 3 additions & 0 deletions src/PrometheusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class PrometheusServiceProvider extends ServiceProvider
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/prometheus.php', 'prometheus');
if (array_key_exists('octane-cache', config('prometheus.bags.' . config('prometheus.default_bag')))) {
$this->mergeConfigFrom(__DIR__ . '/../config/octane.php', 'octane');
}

$this->app->singleton(PrometheusManager::class);
$this->app->alias(PrometheusManager::class, 'prometheus');
Expand Down
Loading
Loading