Request ID Generator (Observability/RequestIdGenerator.php)

synaplan · backend/src/Observability/RequestIdGenerator.php · php · Apache-2.0
security, infra, lang:php, tag:correlation

Generates and sanitizes correlation IDs to trace logs and errors per request.

// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
<?php

declare(strict_types=1);

namespace App\Observability;

/**
 * Generates and sanitises correlation ids.
 *
 * A correlation id ties every log record, event-ring entry and error response
 * of a single request together, so a user-reported id ("I saw abc123") can be
 * traced back to the exact server-side events without exposing any payload.
 *
 * Ids are opaque, non-sensitive tokens — never derived from user data.
 */
final readonly class RequestIdGenerator
{
    /** Request attribute + response header carry the correlation id under this name. */
    public const ATTRIBUTE = '_cor

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key