PHP code example of assetplan / scout-lite-apm

1. Go to this page and download the library: Download assetplan/scout-lite-apm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

assetplan / scout-lite-apm example snippets


use AssetPlan\ScoutLiteAPM\TraceSession;

// Bootstrap (registers your app + configures socket path)
TraceSession::bootstrap('YourAppName', 'your-agent-key');

// Start the request
TraceSession::startRequest();

// Optionally measure queue time automatically

// Custom lifecycle span (e.g. beforeFilter in CakePHP)
$lifecycle = TraceSession::startCustom('Lifecycle/beforeFilter');
// ...
TraceSession::endCustom($lifecycle);

// Instrument a controller span
$controller = TraceSession::startController('UserController', 'index');
// ...
TraceSession::endController($controller);

// Instrument SQL (automatically redacted)
$sqlSpan = TraceSession::startSql('SELECT * FROM users WHERE id = 123');
// ...
TraceSession::endSql($sqlSpan);

// Finish the request
TraceSession::endRequest();

// Flush (optional — you can also register a shutdown handler)
TraceSession::flush();

TraceSession::bootstrap('YourApp', 'your-key', '/tmp/scout-agent.sock');
// or
TraceSession::register('YourApp', 'your-key', '/tmp/scout-agent.sock', '1.0');