1. Go to this page and download the library: Download niladam/laravel-tracing 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/ */
niladam / laravel-tracing example snippets
use Niladam\LaravelTracing\Facades\Tracing;
// in a service provider's boot()
Tracing::always(fn () => ['host' => gethostname()]);
Tracing::authenticated('web', fn (User $user) => [
'team_id' => $user->current_team_id,
]);
Tracing::on(TeamSwitched::class, fn ($e) => ['team_id' => $e->team->id]);
Context::add(['order_id' => $order->id]);
Context::addHidden('idempotency_key', $key); // travels to jobs, never logged
Tracing::traceId(); // 4bf92f3577b34da6a3ce929d0e0e4736
Tracing::traceparent(); // to hand to a client this package does not cover
#[\SensitiveParameter] public string $cardToken, // never recorded at all
Context::addHidden('key', $value); // travels, never logged
'logs' => ['redact' => ['keys' => ['*password*']]], // safety net, descends into nested values
'context' => ['local_only' => ['body.*']], // stays in this process, never written to your queue
'middleware' => [...], // where a trace begins
'record' => [...], // what gets recorded
'context' => [...], // what lands in the context
'logs' => [...], // what reaches a log line
'propagation' => [...], // what leaves the application