2017 © Pedro Peláez
 

library datadog-statsd

DataDog Statsd client

image

lsjroberts/datadog-statsd

DataDog Statsd client

  • Sunday, September 14, 2014
  • by lsjroberts
  • Repository
  • 0 Watchers
  • 0 Stars
  • 108,609 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

PHP DataDog Statsd Client

Forked from https://github.com/DataDog/php-datadogstatsd., (*1)

Installation

Composer

Add the following to your composer.json:, (*2)

"lsjroberts/datadog-statsd": "0.1.*"

Setup

Laravel 4

Add the service provider to your Laravel application in app/config/app.php. In the providers array add:, (*3)

'DataDog\Statsd\StatsdServiceProvider',

And then alias it by adding the facade to the facades array in the same file:, (*4)

'Statsd' => 'DataDog\Statsd\Facades\Illuminate',

Standalone

If you are using another framework or writing a standalone project you can just call:, (*5)

use DataDog\Statsd\Facades\Agnostic as Statsd;

Usage

Increment

To increment things:, (*6)

``` php Statsd::increment('your.data.point'); Statsd::increment('your.data.point', .5); Statsd::increment('your.data.point', 1, array('tagname' => 'value'));, (*7)


### Decrement To decrement things: ``` php Statsd::decrement('your.data.point');

Timing

To time things:, (*8)

``` php $start_time = microtime(true); run_function(); Statsd::timing('your.data.point', microtime(true) - $start_time);, (*9)

Statsd::timing('your.data.point', microtime(true) - $start_time, 1, array('tagname' => 'value'));, (*10)


### Submitting events Requires PHP >= 5.3.0 and the [PECL http](http://www.php.net/manual/en/http.install.php) extension To submit events, you'll need to first configure the library with your Datadog credentials, since the event function submits directly to Datadog instead of sending to a local dogstatsd instance. ``` php $apiKey = 'myApiKey'; $appKey = 'myAppKey'; Statsd::configure($apiKey, $appKey); Statsd::event('A thing broke!', array( 'alert_type' => 'error', 'aggregation_key' => 'test_aggr' )); Statsd::event('Now it is fixed.', array( 'alert_type' => 'success', 'aggregation_key' => 'test_aggr' ));

This is what you'd see your Datadog event stream:, (*11)

screenshot, (*12)

You can find your api and app keys in the API tab., (*13)

For more documentation on the optional values of events, see http://docs.datadoghq.com/api/#events/., (*14)

Note that while sending metrics with this library is fast since it's sending locally over UDP, sending events will be slow because it's sending data directly to Datadog over HTTP. We'd like to improve this in the near future., (*15)

Original Author

Alex Corley - anthroprose@gmail.com, (*16)

The Versions

14/09 2014

dev-master

9999999-dev

DataDog Statsd client

  Sources   Download

MIT

laravel php statsd datadog

25/04 2013

v0.1.1

0.1.1.0

DataDog Statsd client

  Sources   Download

MIT

php statsd datadog

25/04 2013

v0.1.0

0.1.0.0

DataDog Statsd client

  Sources   Download

MIT

php statsd datadog