Skip to content

Commit

Permalink
Merge pull request #10 from peterverraedt/master
Browse files Browse the repository at this point in the history
Allow configuration of run_id, drop xhprof_lib dependency
  • Loading branch information
rez1dent3 authored Nov 25, 2020
2 parents c854866 + 7557f88 commit 690f352
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
return [
'enabled' => true,
'global_middleware' => true,
'path' => '/opt/xhprof',
'output_dir' => null,
'name' => 'xhprof',
'freq' => 1 / 1000,
'extension_name' => 'xhprof',
'provider' => \Bavix\XHProf\Providers\XHProfProvider::class,
'run_id' => uniqid(),
];
12 changes: 7 additions & 5 deletions src/Providers/TidewaysProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class TidewaysProvider implements ProviderInterface
*/
public function enable()
{
$path = config('xhprof.path');
include_once $path . '/xhprof_lib/utils/xhprof_lib.php';
include_once $path . '/xhprof_lib/utils/xhprof_runs.php';
tideways_xhprof_enable(config('xhprof.flags', 0));
}

Expand All @@ -24,8 +21,13 @@ public function enable()
public function disable()
{
$data = tideways_xhprof_disable();
$runs = new XHProfRuns_Default(config('xhprof.output_dir', null));
$runs->save_run($data, config('xhprof.name'));

$run_id = config('xhprof.run_id', null) ?? uniqid();

file_put_contents(
config('xhprof.output_dir', '/tmp') . '/' . $run_id . '.' . config('xhprof.name') . '.xhprof',
serialize($data)
);
}

}
12 changes: 7 additions & 5 deletions src/Providers/XHProfProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class XHProfProvider implements ProviderInterface
*/
public function enable()
{
$path = config('xhprof.path');
include_once $path . '/xhprof_lib/utils/xhprof_lib.php';
include_once $path . '/xhprof_lib/utils/xhprof_runs.php';
xhprof_enable(config('xhprof.flags', 0));
}

Expand All @@ -26,8 +23,13 @@ public function enable()
public function disable()
{
$data = xhprof_disable();
$runs = new XHProfRuns_Default(config('xhprof.output_dir', null));
$runs->save_run($data, config('xhprof.name'));

$run_id = config('xhprof.run_id', null) ?? uniqid();

file_put_contents(
config('xhprof.output_dir', '/tmp') . '/' . $run_id . '.' . config('xhprof.name') . '.xhprof',
serialize($data)
);
}

}

0 comments on commit 690f352

Please sign in to comment.