1. Go to this page and download the library: Download golovanov/traceloom 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/ */
use Golovanov\Traceloom\Configuration;
use Golovanov\Traceloom\Tracer;
$config = Configuration::create(
logDirectory: __DIR__ . '/logs',
maxFileBytes: 50 * 1024 * 1024, // rotate a shard past this size
maxStringBytes: 64 * 1024, // truncate longer strings (clamped to maxRecordBytes)
maxRecordBytes: 256 * 1024, // degrade an event whose line exceeds this (clamped to maxFileBytes)
maxArrayItems: 1000, // limit on EACH array, on its own
maxPayloadNodes: 10000, // node budget for the payload as a whole
maxKeyBytes: 256, // longer keys are truncated with a digest (min 32)
maxDepth: 16, // nesting beyond this becomes [MAX_DEPTH_EXCEEDED]
sensitiveKeys: ['payment_token'],
strictSensitiveKeys: false, // true => match whole keys only, no fragments
directoryMode: 0750,
fileMode: 0640,
retentionDays: 0, // >0 deletes shards older than the cutoff on rotation
trustIncomingTraceId: false, // true reuses an inbound ID instead of quarantining it
failOnError: false,
onError: static function (\Throwable $e): void {
error_log($e->getMessage());
},
);
$tracer = Tracer::fromConfiguration($config);
$trace = $tracer->start($request->header('X-Trace-Id'));
$trace->id(); // freshly generated
$trace->parentId(); // the value the client sent