PHP code example of onema / php-datadogstatsd

1. Go to this page and download the library: Download onema/php-datadogstatsd library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

onema / php-datadogstatsd example snippets


"datadog/php-datadogstatsd": "0.3.*"
 php
DogStatsd::decrement('your.data.point');
 php
$start_time = microtime(true);
run_function();
DogStatsd::timing('your.data.point', microtime(true) - $start_time);

DogStatsd::timing('your.data.point', microtime(true) - $start_time, 1, array('tagname' => 'value'));
 php
$apiKey = 'myApiKey';
$appKey = 'myAppKey';

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