Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bugfix (a static:: statement was forgotten) #27

Merged
merged 1 commit into from
Jul 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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