Track custom metrics in your PHP application with ease.
Custom metrics allow you to monitor specific aspects of your application, such as resource usage, user activity, or performance indicators. Watchlog's PHP library simplifies the process, letting you track metrics with just a few lines of code.
Use the metrics-tracker/watchlog
library to send custom metrics. Install the package and use methods like increment
, decrement
, gauge
, percentage
, or systembyte
to monitor your app's behavior.
use MetricsTracker\Watchlog;
$watchlog = new Watchlog();
// Increment metric by default or a specific value
$watchlog->increment('page_views');
$watchlog->increment('page_views', 5);
// Decrement metric by default or a specific value
$watchlog->decrement('active_users');
$watchlog->decrement('active_users', 2);
// Set a precise value for a metric
$watchlog->gauge('memory_usage', 512);
// Log a percentage metric
$watchlog->percentage('cpu_usage', 75);
// Log a system byte metric
$watchlog->systembyte('disk_space', 1024000);
To get started, install the library using $ composer require metrics-tracker/watchlog
, and integrate it into your PHP application. Follow the sample code to start sending custom metrics immediately.