PHP code example of einlinuus / linuus-observability
1. Go to this page and download the library: Download einlinuus/linuus-observability 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/ */
einlinuus / linuus-observability example snippets
return [
'enabled' => env('OBSERVABILITY_ENABLED', true),
'service_name' => env('OBSERVABILITY_SERVICE_NAME', env('APP_NAME', 'laravel-app')),
'environment' => env('OBSERVABILITY_ENVIRONMENT', env('APP_ENV', 'production')),
'service_version' => env('OBSERVABILITY_SERVICE_VERSION', env('APP_VERSION', 'unknown')),
'log_path' => env('OBSERVABILITY_LOG_PATH', storage_path('logs/observability.jsonl')),
'endpoint' => env('OBSERVABILITY_ENDPOINT'),
'token' => env('OBSERVABILITY_TOKEN'),
'agent' => [
'batch_size' => env('OBSERVABILITY_AGENT_BATCH_SIZE', 100),
'flush_interval_seconds' => env('OBSERVABILITY_AGENT_FLUSH_INTERVAL_SECONDS', 5),
'retry_sleep_seconds' => env('OBSERVABILITY_AGENT_RETRY_SLEEP_SECONDS', 10),
'max_line_bytes' => env('OBSERVABILITY_AGENT_MAX_LINE_BYTES', 262144),
],
];
use Illuminate\Support\Facades\Route;
Route::middleware('observability.request')->group(function (): void {
Route::get('/posts/{post}', ...);
});
'channels' => [
// ...
'linuus-observability' => [
'driver' => 'linuus-observability',
'level' => env('LOG_LEVEL', 'debug'),
],
],
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'linuus-observability'],
],
Log::info('secure note created', ['note_id' => 42]);
use Observability;
Observability::info('secure note created', [
'note_id' => $note->id,
]);
Observability::warning('ip geolocation failed', [
'downstream.service' => 'ip-geolocation',
]);
Observability::audit('user.role_changed', [
'actor.id' => $user->id,
'target.user_id' => $target->id,
'role' => 'admin',
]);
bash
php artisan observability:install
bash
php artisan vendor:publish --tag="linuus-observability-config"
bash
php artisan observability:agent
bash
php artisan observability:restart-agent