function runFunction() { global $apiKey; global $appKey; $startTime = microtime(true); $testArray = array(); for ($i = 0; $i < rand(1, 1000000000); $i++) { $testArray[$i] = $i; // Simulate an event at every 1000000th element if ($i % 1000000 == 0) { echo "Event simulated.\n"; 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')); } } unset($testArray); Datadogstatsd::timing('test.data.point', microtime(true) - $startTime, 1, array('tagname' => 'php_example_tag_2')); }
public static function configure($apiKey, $applicationKey, $datadogHost = 'https://app.datadoghq.com', $submitEventsOver = 'TCP', $localStatsdServer = 'localhost', $localStatsdPort = 8125, $curlVerifySslHost = 2, $curlVerifySslPeer = 1) { self::$__apiKey = $apiKey; self::$__applicationKey = $applicationKey; self::$__datadogHost = $datadogHost; self::$__submitEventsOver = $submitEventsOver; self::$__apiCurlSslVerifyHost = $curlVerifySslHost; self::$__apiCurlSslVerifyPeer = $curlVerifySslPeer; self::$__server = $localStatsdServer; self::$__serverPort = $localStatsdPort; }
/** * Log timing information * * @param string $stat The metric to in log timing info for. * @param float $time The ellapsed time (ms) to log * @param float|1 $sampleRate the rate (0-1) for sampling. * @param array $tags **/ public function timing($key, $value, $sampleRate = 1, $tags = array()) { \Datadogstatsd::timing($key, $value, $sampleRate, $tags); }
<?php require '../libraries/datadogstatsd.php'; Datadogstatsd::increment('web.page_views'); Datadogstatsd::histogram('web.render_time', 15); Datadogstatsd::set('web.uniques', 3); Datadogstatsd::service_check('my.service.check', Datadogstatsd::CRITICAL); //All the following metrics will be sent in a single UDP packet to the statsd server BatchedDatadogstatsd::increment('web.page_views'); BatchedDatadogstatsd::histogram('web.render_time', 15); BatchedDatadogstatsd::set('web.uniques', 3); BatchedDatadogstatsd::flush_buffer(); // Necessary
public static function configure($apiKey, $applicationKey, $datadogHost = 'https://app.datadoghq.com') { self::$__apiKey = $apiKey; self::$__applicationKey = $applicationKey; self::$__datadogHost = $datadogHost; }