Skip to content

Conversation

@Scarbous
Copy link

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues
License MIT

We use tideways in our projects.
When frankenPHP run in worker mode we have to start and stop profiling by our own.

https://support.tideways.com/documentation/setup/installation/frankenphp.html#code-changes-to-frankenphp_handle_request-callback

This PR is a alternativ solution to #62130

I want to use a custom FrankenPhpWorkerRunner like:

use Symfony\Component\Runtime\Runner\FrankenPhpWorkerRunner;

class FrankenPhpTidewaysmWorkerRunner extends FrankenPhpWorkerRunner
{
    protected function getHandler($server, &$sfRequest, &$sfResponse): callable
    {
        $handler = parent::getHandler($server, $sfRequest, $sfResponse);
        return static function () use ($handler) {
            \Tideways\Profiler::start();
            try {
                $handler();
            } catch (\Throwable $e) {
                \Tideways\Profiler::logException($e);
                throw $e;
            } finally {
                \Tideways\Profiler::stop();
            }
        };
    }
}

@GromNaN
Copy link
Member

GromNaN commented Nov 13, 2025

Have you tried using the events: kernel.request, kernel.exception, and kernel.terminate? Or by overriding the Kernel::handle() method?

@yceruto
Copy link
Member

yceruto commented Nov 13, 2025

I think Nicolas' suggestion here #62130 (comment) is simpler for this use case.

@andrew-demb
Copy link
Contributor

I also think that decorating the kernel is a good way to solve such a problem (refs: php-runtime/runtime#183 (comment))

@stof
Copy link
Member

stof commented Nov 13, 2025

Instead of adding such extension point (which will only be available in Symfony 8.1 in 6.5 months from now anyway, given that we are 1.5 month after the feature freeze of 7.4 and 8.0), I suggest you to contact the Tideways team to request automatic instrumentation of the Frankenphp worker mode in the tideways extension. I'm 99% sure it would be possible for them to instrument this frankenphp_handle_request.
Not having to start profiling manually anymore would be the best DX for Tideways for the worker mode, while not requiring to add features in symfony/runtime that we have to maintain forever.
See #62130 (comment) for such suggestion in the other PR.

@nicolas-grekas
Copy link
Member

Let me close as alternatives look indeed better, even if they're not available (yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants