PHP code example of shazam / php-statsd

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

    

shazam / php-statsd example snippets




use Statsd;

// $config = array(...);
// $path = ...

// initialize client
$configuration = new Statsd\Client\Configuration();
$configuration->setHost($config['host'])
    ->setNamespace($config['namespace']);

$statsClient = new Statsd\Client($configuration);

// add stats (you can also add an array of stats with addStats())
$statsClient->addStat(
    array(
        'namespace' => 'endpoints.' . $path, // that will be your stat namespace
        'value' => $executionTime, // calculate it in microseconds
        'type' => 'ms'
    )
);

// send them
$statsClient->sendStats();

javascript
{
    "php-statsd": "2.*"
    }
}