PHP code example of happysanta / php-stat-collector
1. Go to this page and download the library: Download happysanta/php-stat-collector 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/ */
happysanta / php-stat-collector example snippets
namespace App;
class Metric extends \Hs\StatCollector
{
public static function isWriteEnable():bool {
return !!config("app.enabled_grafana", "1");
}
public static function getAppName():string
{
return mb_strtolower(config("app.name", "bad_app"));
}
public static function fatalError() {
self::sum("fatal_error", 1);
}
public static function snippetGenerationTime($time) {
self::avg("snippet_generation", $time);
}
public static function test() {
self::sum("test_metric", 1);
}
public static function sendNotifyError() {
self::sum("send_notify_error", 1);
}
public static function sendNotifyDone() {
self::sum("send_notify_done", 1);
}
}
bash
composer