PHP code example of easyswoole / trace

1. Go to this page and download the library: Download easyswoole/trace 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/ */

    

easyswoole / trace example snippets




$t = new \EasySwoole\Trace\TrackerManager();

$tracker = $t->getTracker('test');

$tracker->addAttribute('userName','用户1');
$tracker->addAttribute('userToken','userToken');

//sql one
$tracker->setPoint('查询用户余额',[
    'sql'=>'sql statement one'
]);
//模拟sql one执行
//$mode->func();
usleep(3000);
$tracker->endPoint('查询用户余额');

//curl api
$point = $tracker->setPoint('消息api查询',[
    'curlParamOne'=>time()
]);
//模拟curl执行 timeout
//$mode->func();
sleep(1);
$point->endPoint($point::STATUS_FAIL,[
    'curlResult'=>null,
    'msg'=>'超时'
]);

echo $tracker->toString();