PHP code example of vend / statsd

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

    

vend / statsd example snippets


use Vend\Statsd\Client;
use Vend\Statsd\Socket;
use Vend\Statsd\Factory;

$client = new Client(
    new Socket(),
    new Factory()
);

$client->increment('some.metric_key'); // incremented by 1
$client->decrement('some.metric_key'); // decremented by 1
$client->counter('some.counter', 3);   // incremented by 3
$client->gauge('some.gauge', 10);
$client->timer('some.timer', 0.25);
$client->set('some.set', 'some_value');

$client->flush(); // actually sends the metrics

$socket = new Socket('127.0.0.1', 8125);
$factory = new Factory();

$socket->open();
$socket->write($factory->increment('some.key')->getData());
$socket->close();