Giter VIP home page Giter VIP logo

php-datadogstatsd's Introduction

PHP DataDog StatsD Client

This is an extremely simple PHP datadogstatsd client

Installation

Clone repository at github.com/DataDog/php-datadogstatsd

Setup

require './libraries/datadogstatsd.php';

Usage

Increment

To increment things:

DataDogStatsD::increment('your.data.point');
DataDogStatsD::increment('your.data.point', .5);
DataDogStatsD::increment('your.data.point', 1, array('tagname' => 'value'));

Decrement

To decrement things:

DataDogStatsD::decrement('your.data.point');

Timing

To time things:

$start_time = microtime(true);
run_function();
DataDogStatsD::timing('your.data.point', microtime(true) - $start_time);

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

Submitting events

Requires PHP >= 5.3.0 with the curl-php5 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.

$apiKey = 'myApiKey';
$appKey = 'myAppKey';

DataDogStatsD::configure($apiKey, $appKey);
DataDogStatsD::event('A thing broke!', array(
	'alert_type'      => 'error',
	'aggregation_key' => 'test_aggr'
));
DataDogStatsD::event('Now it is fixed.', array(
	'alert_type'      => 'success',
	'aggregation_key' => 'test_aggr'
));

This is what you'd see your Datadog event stream:

screenshot

You can find your api and app keys in the API tab.

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

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.

Author

Alex Corley - [email protected]

php-datadogstatsd's People

Contributors

alq666 avatar bunelr avatar chiragbajaj avatar clutchski avatar conorbranagan avatar djinn avatar eirikhm avatar seejohnrun avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.