PHP code example of classmarkets / statsd

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

    

classmarkets / statsd example snippets


$statsd = new \Classmarkets\Statsd;
$statsd->gauge("my.favorite.numbers", 73); // see what I did there?

$statsd = new \Classmarkets\Statsd;
$statsd->count('sheep', 3);

$statsd = new \Classmarkets\Statsd;
$statsd->timeThis('critical.query', function() use ($db) {
    $db->executeCriticalQuery();
});

$statsd = new \Classmarkets\Statsd('localhost', 7000); // default localhost:8125

$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$statsd = new \Classmarkets\Statsd('localhost', 7000, $socket); // default localhost:8125

$statsd = new \Classmarkets\Statsd;
$stats->count('numpoints', 123, 0.1);
 php
$statsd = new \Classmarkets\Statsd;
$statsd->timing('critical.query', 18);