diff --git a/src/OctaneMiddleware.php b/src/OctaneMiddleware.php index 22d5916..02a1ae9 100644 --- a/src/OctaneMiddleware.php +++ b/src/OctaneMiddleware.php @@ -17,8 +17,8 @@ class OctaneMiddleware */ public function handle(Request $request, Closure $next) { - if (!class_exists('Tideways\Profiler') || php_sapi_name() !== 'cli') { - // only run when Tideways is installed and the CLI sapi is used (thats how Swoole/RR work) + if (!class_exists('Tideways\Profiler') || !in_array(php_sapi_name(), ['cli', 'frankenphp'], true)) { + // only run when Tideways is installed and the CLI/frankenphp sapi is used (thats how Swoole/RR work) return $next($request); } @@ -38,7 +38,7 @@ public function handle(Request $request, Closure $next) \Tideways\Profiler::setCustomVariable('http.method', $request->getMethod()); \Tideways\Profiler::setCustomVariable('http.url', $request->getPathInfo()); - if (class_exists('Tideways\Profiler', 'markAsWebTransaction')) { + if (method_exists('Tideways\Profiler', 'markAsWebTransaction')) { \Tideways\Profiler::markAsWebTransaction(); } diff --git a/tests/OctaneMiddlewareTest.php b/tests/OctaneMiddlewareTest.php index 258244e..a795c9a 100644 --- a/tests/OctaneMiddlewareTest.php +++ b/tests/OctaneMiddlewareTest.php @@ -16,8 +16,6 @@ public function setUp(): void $this->markTestSkipped('Tideways\Profiler is not installed.'); } - $this->assertEquals('basic', ini_get('tideways.monitor')); - \Tideways\Profiler::stop(); } @@ -46,9 +44,12 @@ function withTideawysDaemon(\Closure $callback = null, $flags = 0) { $callback = $callback ?: function() {}; $address = "tcp://127.0.0.1:64111"; - ini_set("tideways.connection", $address); + ini_set('tideways.connection', $address); ini_set('tideways.api_key', 'abcdefg'); ini_set('tideways.sample_rate', 0); + ini_set('tideways.monitor', 'basic'); + putenv('TIDEWAYS_CONNECTION=' . $address); + $_SERVER['TIDEWAYS_CONNECTION'] = $address; if (ini_get("tideways.connection") !== $address) { throw new \RuntimeException('Could not set tideways.connection to ' . $address); }