-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robin Mulder
committed
Nov 8, 2024
1 parent
c8081fb
commit a3ae3a3
Showing
7 changed files
with
173 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace JustBetter\XhprofProfiler\Model\Profiler\Driver; | ||
|
||
use JustBetter\XhprofProfiler\Api\DriverInterface; | ||
use Magento\Framework\App\DeploymentConfig; | ||
use Magento\Framework\Exception\FileSystemException; | ||
use Magento\Framework\Exception\RuntimeException; | ||
use SpiralPackages\Profiler\Driver\XhprofDriver; | ||
use SpiralPackages\Profiler\Storage\WebStorage; | ||
use Symfony\Component\HttpClient\NativeHttpClient; | ||
|
||
|
||
class Buggregator implements DriverInterface | ||
{ | ||
public const IGNORED_FUNCTIONS_KEY = 'ignored_functions'; | ||
|
||
public function __construct( | ||
protected XhprofDriver $driver, | ||
protected DeploymentConfig $deploymentConfig, | ||
) | ||
{} | ||
|
||
public function start(): void | ||
{ | ||
$this->driver->start( | ||
[ | ||
self::IGNORED_FUNCTIONS_KEY => ['SpiralPackages\Profiler\Profiler::end'], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Terminates the current profiling session and stores the results. | ||
* @param array $tags Optional tags to attach to the profiling data. | ||
* @return void | ||
* @throws FileSystemException | ||
* @throws RuntimeException | ||
*/ | ||
public function end(array $tags = []): void | ||
{ | ||
$result = $this->driver->end(); | ||
$endpoint = $this->deploymentConfig->get('xhprofprofiler/endpoint'); | ||
$appName = $this->deploymentConfig->get('xhprofprofiler/app_name'); | ||
if (!empty($appName) && !empty($endpoint) && is_string($endpoint) && is_string($appName)) { | ||
$storage = new WebStorage(new NativeHttpClient(), $endpoint); | ||
$storage->store( | ||
$appName, | ||
$tags, | ||
new \DateTimeImmutable(), | ||
$result | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace JustBetter\XhprofProfiler\Model\Profiler\Driver; | ||
|
||
use Magento\Framework\App\DeploymentConfig; | ||
use Xhgui\Profiler\Profiler; | ||
use Xhgui\Profiler\ProfilingFlags; | ||
|
||
class XHGui implements \JustBetter\XhprofProfiler\Api\DriverInterface | ||
{ | ||
public Profiler $driver; | ||
|
||
public function __construct( | ||
protected DeploymentConfig $deploymentConfig, | ||
array $config = [] | ||
) | ||
{ | ||
$this->initializeDriver($config); | ||
} | ||
|
||
private function initializeDriver(array $config): void | ||
{ | ||
$this->driver = new Profiler($config); | ||
} | ||
|
||
public function start(): void | ||
{ | ||
$this->driver->enable(); | ||
} | ||
|
||
public function end(array $tags = []): void | ||
{ | ||
$this->driver->save($this->driver->disable()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters