Skip to content

Instantly share code, notes, and snippets.

@mageekguy
Last active August 29, 2015 14:08
Show Gist options
  • Save mageekguy/963037259c871e62501e to your computer and use it in GitHub Desktop.
Save mageekguy/963037259c871e62501e to your computer and use it in GitHub Desktop.
<?php
require __DIR__ . '/vendor/autoload.php';
use estvoyage\statsd;
$connection = new statsd\connection\internet(new statsd\address);
(new statsd\packet)
->adds([ new statsd\metric\timing('speed1', 1), new statsd\metric\gauge('gauge1', 5), new statsd\metric\timing('speed2', 3) ])
->writeOn($connection)
;
@mageekguy
Copy link
Author

In a terminal:

# nc -u -l 8125

In an another terminal:

# git clone https://github.com/estvoyage/statsd
# cd statsd
# curl -sS https://getcomposer.org/installer | php
# php composer.phar install
# curl https://gist.githubusercontent.com/mageekguy/963037259c871e62501e/raw/90c54bb0fc66e919b1461d1e9502fff90d5f7608/statsd:%20send%20a%20packet%20with%20several%20metrics > test.php
# php test.php

In the first terminal, you should see:

# nc -u -l 8125
speed1:1|ms
gauge1:5|g
speed2:3|ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment