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')); }
<?php require '../libraries/datadogstatsd.php'; DataDogStatsD::increment('web.page_views'); DataDogStatsD::histogram('web.render_time', 15); DataDogStatsD::set('web.uniques', 3);
<?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