diff --git a/config/config.php b/config/config.php index 05a889b..262cede 100644 --- a/config/config.php +++ b/config/config.php @@ -6,4 +6,6 @@ 'path' => '/opt/xhprof', 'name' => 'xhprof', 'freq' => 1 / 1000, + 'extension_name' => 'xhprof', + 'provider' => \Bavix\XHProf\Providers\XHProfProvider::class, ]; diff --git a/src/Provides/TidewaysProvider.php b/src/Provides/TidewaysProvider.php new file mode 100644 index 0000000..730d8f3 --- /dev/null +++ b/src/Provides/TidewaysProvider.php @@ -0,0 +1,31 @@ +save_run($data, config('xhprof.name')); + } + +} diff --git a/src/Services/XHProfService.php b/src/Services/XHProfService.php index 5246c41..6ab4ffe 100644 --- a/src/Services/XHProfService.php +++ b/src/Services/XHProfService.php @@ -3,6 +3,7 @@ namespace Bavix\XHProf\Services; use Bavix\XHProf\Providers\ProviderInterface; +use Bavix\XHProf\Providers\TidewaysProvider; use Bavix\XHProf\Providers\XHProfProvider; use function extension_loaded; use function mt_getrandmax; @@ -21,7 +22,7 @@ class XHProfService */ public function __construct() { - if (!extension_loaded('xhprof')) { + if (!extension_loaded(config('xhprof.extension_name', 'xhprof'))) { return; } @@ -31,7 +32,15 @@ public function __construct() $freq = config('xhprof.freq', 0.01); if ($freq >= (mt_rand() / mt_getrandmax())) { - $this->provider = new XHProfProvider(); + switch (config('xhprof.provider', XHProfProvider::class)) { + case TidewaysProvider::class: + $this->provider = new TidewaysProvider(); + break; + default: + case XHProfProvider::class: + $this->provider = new XHProfProvider(); + break; + } } }