This is an extremely simple PHP StatsD client for caremerge built on top of php-statsd and php-datadogstatsd
Requires PHP >= 5.3.0.
Use the composer.json file
composer install
Note: The first version shipped in composer is 0.0.3
Clone repository at github.com/FarrukhNaeem/php-statsd
Setup: require './src/CareStats.php';
To instantiate a DogStatsd object using composer
:
require __DIR__ . '/vendor/autoload.php';
use StatsDC\CareStats;
$statsd = new CareStats();
CareStats constructor, takes a configuration array. The configuration can take any of the following values (all optional):
host
: the host of your Statsd server, default tolocalhost
port
: the port of your Statsd server. default to8125
The 'tags' argument can be a array or a string. Value can be set to null
.
To increment things:
$statsd->increment('your.data.point');
$statsd->increment('your.data.point', .5);
To decrement things:
$statsd->decrement('your.data.point');
To time things:
$start_time = microtime(true);
run_function();
$statsd->microtiming('your.data.point', microtime(true) - $start_time);
$statsd->microtiming('your.data.point', microtime(true) - $start_time, 1, array('tagname' => 'value'));