PHP code example of eleme / statsd
1. Go to this page and download the library: Download eleme/statsd 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/ */
eleme / statsd example snippets
'providers' => array(
// ...
'League\StatsD\Laravel\Provider\StatsdServiceProvider',
)
'aliases' => array(
// ...
'Statsd' => 'League\StatsD\Laravel\Facade\StatsdFacade',
)
'providers' => [
// ...
League\StatsD\Laravel5\Provider\StatsdServiceProvider::class,
]
'aliases' => [
// ...
'Statsd' => League\StatsD\Laravel5\Facade\StatsdFacade::class,
]
$statsd = new League\StatsD\Client();
$statsd->configure(array(
'host' => '127.0.0.1',
'port' => 8125,
'namespace' => 'example'
));
$statsd1 = StatsD\Client::instance('server1')->configure(array(...));
$statsd2 = StatsD\Client::instance('server2')->configure(array(...));
$statsd->increment('web.pageview');
$statsd->decrement('storage.remaining');
$statsd->increment(array(
'first.metric',
'second.metric'
), 2);
$statsd->increment('web.clicks', 1, 0.5);
$statsd->gauge('api.logged_in_users', 123456);
$userID = 23;
$statsd->set('api.unique_logins', $userID);
$statsd->timing('api.response_time', 256);
$statsd->time('api.dbcall', function () {
// this code execution will be timed and recorded in ms
});