Statsd (Object Oriented) client library for PHP

Installs: 119 446

Dependents: 3

Stars: 81

Watchers: 10

Forks: 23

Open Issues: 4

Language: PHP

v1.0.16 2015-04-27 08:12 UTC


Be careful, see the Upgrading section for <= v1.0.4, there's a BC.

Build Status Latest Stable Version Total Downloads

statsd-php-client is an Open Source, and Object Oriented Client for etsy/statsd written in php

  • StatsdDataFactory creates the Liuggio\StatsdClient\Entity\StatsdDataInterface Objects

  • Sender just sends data over the network (there are many sender)

  • StatsdClient sends the created objects via the Sender to the server

Why use this library instead the statsd/php-example?

  • You are wise.

  • You could also use monolog to redirect data to statsd

  • This library is tested.

  • This library optimizes the messages to send, compressing multiple messages in individual UDP packets.

  • This library pays attention to the maximum length of the UDP.

  • This library is made by Objects not array, but it also accepts array.

  • You do want to debug the packets, and using SysLogSender the packets will be logged in your syslog log (on debian-like distro: tail -f /var/log/syslog)


  1. create the Sender

  2. create the Client

  3. create the Factory

  4. the Factory will help you to create data

  5. the Client will send the data

Standard Usage

use Liuggio\StatsdClient\StatsdClient,
// use Liuggio\StatsdClient\Sender\SysLogSender;

$sender = new SocketSender(/*'localhost', 8126, 'udp'*/);
// $sender = new SysLogSender(); // enabling this, the packet will not send over the socket

$client  = new StatsdClient($sender);
$factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData');
$service = new StatsdService($client, $factory);

// create the metrics with the service
$service->timing('usageTime', 100);
$service->gauge('gaugor', 333);
$service->set('uniques', 765);

// send the data to statsd

Usage with Monolog

use Liuggio\StatsdClient\StatsdClient,
// use Liuggio\StatsdClient\Sender\SysLogSender;

use Monolog\Logger;
use Liuggio\StatsdClient\Monolog\Handler\StatsDHandler;

$sender = new SocketSender(/*'localhost', 8126, 'udp'*/);
// $sender = new SysLogSender(); // enabling this, the packet will not send over the socket
$client = new StatsdClient($sender);
$factory = new StatsdDataFactory();

$logger = new Logger('my_logger');
$logger->pushHandler(new StatsDHandler($client, $factory, 'prefix', Logger::DEBUG));

$logger->addInfo('My logger is now ready');

the output will be: prefix.my_logger.INFO.My-logger:1|c" 36 Bytes

Short Theory

Easily Install StatSD and Graphite

In order to try this application monitor you have to install etsy/statsd and Graphite

see this blog post to install it with vagrant Easy install statsd graphite.


StatsD is a simple daemon for easy stats aggregation


Graphite is a Scalable Realtime Graphing

The Client sends data with UDP (faster)


Active contribution and patches are very welcome. To keep things in shape we have quite a bunch of unit tests. If you're submitting pull requests please make sure that they are still passing and if you add functionality please take a look at the coverage as well it should be pretty high :)

  • First fork or clone the repository
git clone git://
cd statsd-php-client
  • Install vendors:
composer.phar install
  • This will give you proper results:
phpunit --coverage-html reports


BC from the v1.0.4 version, see Sender and Client differences.

Core developers:

This project is actively mantained by David Moreau AKA @dav-m85 and @liuggio