PHP Custom Metrics Made Simple

Track custom metrics in your PHP application with ease.

What are Custom Metrics?

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.

Custom Metrics

How to Send Metrics with Watchlog

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.

  1. Increment: Increase a metric by a specific value (default: 1).
  2. Decrement: Decrease a metric by a specific value (default: 1).
  3. Gauge: Record a precise value, such as memory usage or user sessions.
  4. Percentage: Send percentage values (0 to 100).
  5. System Byte: Log metrics like disk space usage in bytes.

Sample Code

  
  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);
  
        

Getting Started

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.

View Documentation

Monitor PHP Metrics Effortlessly

Sign up for Watchlog and simplify custom metric tracking for your PHP applications.

View Pricing