Skip to content

Commit

Permalink
Blackfire: Add distributed profilling support
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Aug 25, 2023
1 parent 869f0c7 commit 6386f93
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Parallel/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace PHPStan\Parallel;

use BlackfireProbe;
use Exception;
use PHPStan\ShouldNotHappenException;
use React\EventLoop\LoopInterface;
use React\EventLoop\TimerInterface;
use React\Stream\ReadableStreamInterface;
use React\Stream\WritableStreamInterface;
use Throwable;
use function class_exists;
use function fclose;
use function is_string;
use function rewind;
Expand Down Expand Up @@ -60,9 +62,16 @@ public function start(callable $onData, callable $onError, callable $onExit): vo
if ($tmpStdErr === false) {
throw new ShouldNotHappenException('Failed creating temp file for stderr.');
}

$env = $_ENV;
if (class_exists('BlackfireProbe') && BlackfireProbe::isEnabled()) {
$probe = BlackfireProbe::getMainInstance();
$env['BLACKFIRE_QUERY'] = $probe->createSubProfileQuery();
}

$this->stdOut = $tmpStdOut;
$this->stdErr = $tmpStdErr;
$this->process = new \React\ChildProcess\Process($this->command, null, null, [
$this->process = new \React\ChildProcess\Process($this->command, null, $env, [
1 => $this->stdOut,
2 => $this->stdErr,
]);
Expand Down

0 comments on commit 6386f93

Please sign in to comment.