Profiling Programatically in PHP Code

If you want programmatic control over Tideways Profiling, or use it inside Worker scripts, React.PHP, then you can directly start profiling from PHP.

bootstrap.php
<?php

if (class_exists('Tideways\Profiler')) {
    \Tideways\Profiler::start([
        'api_key' => 'YOUR API KEY',
        'service' => 'web',
        'sample_rate' => 25,
    ]);
}

Or without parameters, because they are already set in php.ini or via Environment Variables:

bootstrap.php
<?php

if (class_exists('Tideways\Profiler')) {
    \Tideways\Profiler::start();
}

Tideways automatically stops when the request shuts down. If you are profiling multiple traces in a single PHP request, then you can force the Tideways Profiler to stop manually:

<?php

if (class_exists('Tideways\Profiler')) {
     \Tideways\Profiler::stop();
}
Still need help? Email [email protected]