Skip to content

Commit

Permalink
Merge pull request #27 from DataDog/etienne/class_name_update
Browse files Browse the repository at this point in the history
Minor bugfix (a static:: statement was forgotten)
  • Loading branch information
elafarge committed Jul 27, 2015
2 parents b5dd651 + c1293ad commit 966feb9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
16 changes: 8 additions & 8 deletions examples/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
require '../libraries/datadogstatsd.php';


DataDogStatsD::increment('web.page_views');
DataDogStatsD::histogram('web.render_time', 15);
DataDogStatsD::set('web.uniques', 3 /* a unique user id */);
DataDogStatsD::service_check('my.service.check', DataDogStatsD::CRITICAL);
Datadogstatsd::increment('web.page_views');
Datadogstatsd::histogram('web.render_time', 15);
Datadogstatsd::set('web.uniques', 3 /* a unique user id */);
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 /* a unique user id */);
BatchedDatadogStatsD::flush_buffer(); // Necessary
BatchedDatadogstatsd::increment('web.page_views');
BatchedDatadogstatsd::histogram('web.render_time', 15);
BatchedDatadogstatsd::set('web.uniques', 3 /* a unique user id */);
BatchedDatadogstatsd::flush_buffer(); // Necessary

?>
34 changes: 17 additions & 17 deletions examples/expandedExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,61 @@

require '../libraries/datadogstatsd.php';

$apiKey = '046a22167c96272932f7f95753ceb81013e1fcac';
$apiKey = '046a22167c96272932f7f95753ceb81013e1fcac';
$appKey = '2167c96272932f013e1fcac7f95753ceb81046a2';
DataDogStatsD::configure($apiKey, $appKey);
Datadogstatsd::configure($apiKey, $appKey);

$runFor = 5; // Set to five minutes. Increase or decrease to have script run longer or shorter.
$scriptStartTime = time();
$scriptStartTime = time();

echo "Script starting.\n";

// Send metrics and events for 5 minutes.
while ( time() < $scriptStartTime + ($runFor * 60) ) {
while ( time() < $scriptStartTime + ($runFor * 60) ) {

$startTime1 = microtime(true);
DataDogStatsD::increment('web.page_views');
DataDogStatsD::histogram('web.render_time', 15);
DataDogStatsD::set('web.uniques', 3 /* A unique user id */);
Datadogstatsd::increment('web.page_views');
Datadogstatsd::histogram('web.render_time', 15);
Datadogstatsd::set('web.uniques', 3 /* A unique user id */);

runFunction();
DataDogStatsD::timing('test.data.point', microtime(true) - $startTime1, 1, array('tagname' => 'php_example_tag_1'));
Datadogstatsd::timing('test.data.point', microtime(true) - $startTime1, 1, array('tagname' => 'php_example_tag_1'));

sleep(1); // Sleep for one second

}
}

echo "Script has completed.\n";

function runFunction() {

global $apiKey;
global $appKey;

$startTime = microtime(true);

$testArray = array();
for ($i = 0; $i < rand(1,1000000000); $i++) {
$testArray[$i] = $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(
Datadogstatsd::event('A thing broke!', array(
'alert_type' => 'error',
'aggregation_key' => 'test_aggr'
));
DataDogStatsD::event('Now it is fixed.', array(
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'));
Datadogstatsd::timing('test.data.point', microtime(true) - $startTime, 1, array('tagname' => 'php_example_tag_2'));

}

?>
?>
2 changes: 1 addition & 1 deletion libraries/datadogstatsd.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static function report($udp_message) {
}

public static function report_metric($udp_message) {
report($udp_message);
static::report($udp_message);
}

public static function flush_buffer() {
Expand Down

0 comments on commit 966feb9

Please sign in to comment.