metrics-tracker / watchlog
A PHP package for sending metrics.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
pkg:composer/metrics-tracker/watchlog
Requires
- guzzlehttp/guzzle: ^7.0
README
Introduction
The Watchlog class is a simple PHP class for sending various types of metrics to a server. It uses the Guzzle HTTP client for making asynchronous HTTP requests.
Setup
- 
Install Watchlog: Ensure you have the Watchlog package installed via Composer. Run the following command in your project directory: composer require metrics-tracker/watchlog 
- 
Include the WatchlogClass: Ensure your PHP script includes theWatchlogclass. Use an autoloader or include the class file directly.
Usage
Here are the methods available in the Watchlog class and how to use them:
- 
Increment a Metric: use MetricsTracker\Watchlog; $watchlog = new Watchlog(); $watchlog->increment('page_views'); // Optionally increment by a different value $watchlog->increment('page_views', 5); 
- 
Decrement a Metric: $watchlog->decrement('active_users'); // Optionally decrement by a different value $watchlog->decrement('active_users', 2); 
- 
Set a Gauge Value: $watchlog->gauge('memory_usage', 512); 
- 
Set a Percentage Value: $watchlog->percentage('cpu_usage', 75); 
- 
Set a System Byte Value: $watchlog->systembyte('disk_space', 1024000); 
Notes
- Ensure the server agent is set up to handle the incoming metric requests.
- Each method (increment,decrement,gauge,percentage,systembyte) sends a metric to the server with the specified method, metric name, and value.
- The sendMetricmethod is a private method used internally to handle the HTTP request logic.
This documentation should help you understand how to set up and use the Watchlog class for tracking metrics in your PHP application.