composer require xelent/xelentwatch
php artisan vendor:publish --tag=xelentwatch-config
.env:
XELENTWATCH_ENABLED=true
XELENTWATCH_TOKEN=your-app-token
XELENTWATCH_INGEST_URI=your-tcp-server:2407
php artisan config:clear and test with a manual event:
use Xelent\Xelentwatch\Facades\Xelentwatch;
Xelentwatch::event('test_event', ['key' => 'value']);
Automatically track request performance by adding to app/Providers/AppServiceProvider.php:
public function boot()
{
if (config('xelentwatch.enabled')) {
\Xelent\Xelentwatch\Facades\Xelentwatch::trackRequests();
}
}
Request Tracking:
// Enable globally (AppServiceProvider)
Xelentwatch::trackRequests();
// Or per-route (RouteServiceProvider)
Xelentwatch::trackRequest($request);
Artisan Command Monitoring:
use Xelent\Xelentwatch\Facades\Xelentwatch;
protected function handle()
{
Xelentwatch::trackCommand($this);
// Command logic
}
Custom Events:
Xelentwatch::event('user.created', [
'user_id' => $user->id,
'metadata' => ['plan' => $user->plan]
]);
public function handle($request, Closure $next)
{
Xelentwatch::trackRequest($request);
return $next($request);
}
try {
// Risky code
} catch (\Exception $e) {
Xelentwatch::exception($e);
throw $e;
}
schedule() calls:
$schedule->command('backup:run')->everyMinute()
->via(function () {
Xelentwatch::trackCommand(new \Illuminate\Console\Scheduling\Event($this));
});
Adjust sampling rates in config/xelentwatch.php to balance load:
'sampling' => [
'requests' => 0.5, // 50% of requests
'exceptions' => 1.0, // All exceptions
],
TCP Connection Issues:
XELENTWATCH_INGEST_URI is reachable (firewall, Docker networking).telnet <uri> 2407 or nc -zv <uri> 2407.XELENTWATCH_TIMEOUT (default: 1s) to avoid blocking:
'ingest' => [
'timeout' => 2, // 2 seconds
],
Sampling Overhead:
1.0) may impact performance.0.1 for requests/commands, then adjust.Token Leaks:
XELENTWATCH_TOKEN in client-side code or logs..env validation (Laravel 8+):
// config/validation.php
'xelentwatch_token' => 'required_if:xelentwatch_enabled,true',
Queue Delays:
Xelentwatch::event(..., ['sync' => true]) for critical data.Enable Debug Mode:
XELENTWATCH_DEBUG=true
Logs payloads to storage/logs/xelentwatch.log.
Validate Payloads: Check raw TCP output with:
nc -l 2407 | hexdump -C
Custom Payloads:
Override the payload formatter in app/Providers/XelentwatchServiceProvider.php:
public function boot()
{
Xelentwatch::extendPayload(function ($payload) {
$payload['custom'] = ['app_version' => '1.0.0'];
return $payload;
});
}
Batch Processing: For high-volume apps, implement batching:
Xelentwatch::setBatchSize(100); // Send every 100 events
Xelentwatch::setBatchTimeout(30); // Flush every 30s
Environment-Specific Config:
Use config/xelentwatch.php overrides:
return [
'environment' => env('APP_ENV'),
'sampling' => [
'requests' => env('APP_ENV') === 'local' ? 0.0 : 0.5,
],
];
/health endpoint that checks telemetry connectivity:
Route::get('/health', function () {
try {
Xelentwatch::ping();
return response()->json(['status' => 'ok']);
} catch (\Exception $e) {
return response()->json(['status' => 'error'], 500);
}
});
'ingest' => [
'retries' => 3,
'retry_delay' => 100, // ms
],
Xelentwatch::filterPayload(function ($payload) {
unset($payload['data']['password']);
return $payload;
});
How can I help you explore Laravel packages today?