1. Go to this page and download the library: Download myoperator/metrics 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/ */
myoperator / metrics example snippets
use MyOperator\Metrics\Metrics;
Metrics::setApplication('your-app-name'); // Your metrics base name
Metrics::setConnection('localhost', 8125); // UDP connection host and port
Metrics::getInstance()->startTiming('fn.time');
$this->consumeTime();
Metrics::getInstance()->endTiming('fn.time'); //Same name that you started logging time with
$user->login(); //some method to login user
metrics::getinstance()->count('user.login', 1); //increase user login by 1
$items = $queue->getItems(); //some method to get items in queue
metrics::getinstance()->count('queue.item.count', count($items)); //Send number of items in queue
Metric::getInstance()->startTiming('task.time'); //String for reference
$task->takeTime(); //Time taking task
Metric::getInstance()->endTiming('task.time'); //End the time