PHP code example of robertogallea / laravel-metrics
1. Go to this page and download the library: Download robertogallea/laravel-metrics 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/ */
robertogallea / laravel-metrics example snippets
$registry = resolve(MetricRegistry::class);
$marker = $registry->meter('metric-name');
$marker->mark();
// or you can use facade
$marker = \Metrics::meter('metric-name');
$marker->mark();
$registry = resolve(MetricRegistry::class);
$timer = $registry->meter('metric-name', MeterType::TIMER);
$timerId = $timer->start();
// or you can use facade
$timer = \Metrics::meter('metric-name', MeterType::TIMER);
$timerId = $timer->start();
doSomething();
$timer->stop($timerId);
$registry = resolve(MetricRegistry::class);
$meter = $registry->meter('meter-name');
$meter->get(); // gets the entire dataset for the meter
$from = Carbon::yesterday();
$meter->after($from)->get(); // gets the dataset for meters recorded after $from
$to = Carbon::tomorrow();
$meter->before($from)->get(); // gets the dataset for meters recorded before $to
$meter->between($from, $to)->get(); // gets the dataset for meters recorded between $from and $to