PHP code example of rainwaves / scale-monitor-client
1. Go to this page and download the library: Download rainwaves/scale-monitor-client 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/ */
rainwaves / scale-monitor-client example snippets
use Rainwaves\ScaleMonitorClient\ScaleMonitor;
app(ScaleMonitor::class)->heartbeat('scheduler');
app(ScaleMonitor::class)->error('high', 'RuntimeException', 'Payment gateway timed out.');
app(ScaleMonitor::class)->metric('queue_depth', ['value' => 42]);
app(ScaleMonitor::class)->event('user_registered', fingerprint: 'signup-flow');
app(ScaleMonitor::class)->deployment(release: 'v1.4.0', commitSha: $sha, status: 'succeeded');
// routes/console.php
Schedule::command('scale-monitor:heartbeat scheduler')->everyMinute();
// AppServiceProvider::boot()
Event::listen(JobFailed::class, \Rainwaves\ScaleMonitorClient\Listeners\ReportFailedJobToScaleMonitor::class);
// app/Exceptions/Handler.php (or wherever your Handler lives)
use Rainwaves\ScaleMonitorClient\Exceptions\ReportsToScaleMonitor;
class Handler
{
use ReportsToScaleMonitor;
}
// bootstrap/app.php
->withExceptions(function (Exceptions $exceptions) {
$exceptions->reportable(fn (Throwable $e) =>
app(Handler::class)->reportExceptionToScaleMonitor($e, severity: 'high'));
})
// routes/api.php
Route::get('/monitoring/v1/health', \Rainwaves\ScaleMonitorClient\Http\Controllers\HealthController::class)
->middleware('scale-monitor.signature');
use Rainwaves\ScaleMonitorClient\Support\{HealthCheckRegistry, CheckResult};
app(HealthCheckRegistry::class)->registerCheck('google_maps', function () {
$incident = OperationalIncident::where('service', 'google-maps')->where('status', 'open')->first();
return $incident === null
? CheckResult::healthy('google_maps')
: CheckResult::critical('google_maps', $incident->message, errorCode: 'BILLING_DISABLED');
});
'storage' => [
'disks' => ['s3' => 'supabase', 'public' => 'local'],
],
bash
php artisan scale-monitor:deployment --release="$GITHUB_SHA" --commit="$GITHUB_SHA" --status=succeeded || true
bash
php artisan scale-monitor:ping
bash
php artisan scale-monitor:delivery-status