Download the PHP package genai/trace without Composer
On this page you can find all versions of the php package genai/trace. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package trace
Short Description Request correlation IDs for centralized logging. A TraceInterceptor reads X-Request-Id (or generates one), exposes it via a TraceContext bean + a global trace_id(), echoes it on the response, and a Monolog processor stamps it on every log line. PHP 5.3-safe at runtime.
License Apache-2.0
Informations about the package trace
genai/trace
Request correlation IDs for centralized logging. Each request gets a trace id (read from the inbound header or generated), threaded through the request and stamped on every log line — so you can grep one id and see the whole request's journey across services. PHP 5.3.29-safe at runtime.
How it works
TraceInterceptor(outermost) readsX-Request-Idfrom the request (set by an upstream gateway/service), or generates a 128-bit hex id when absent; stores it onTraceContext; and echoes it on the response.TraceContextholds the id for the request (a container singleton) and is also exposed statically, so:- the global
trace_id()helper works in templates/error pages, and - the Monolog
TraceProcessorcan read it without DI.
- the global
- Downstream calls should forward the same header to continue the chain.
Use it
-
composer require genai/trace— that's it. TheTraceInterceptoris self-enabling: it carries#[Intercept(order: -30)]and lives in a scanned bundle namespace, so installing the package turns it on (no app wiring). Every response now getsX-Request-Idandtrace_id()works. -
Stamp it on your logs (Monolog):
- Optional config (
app.ini):
Now every response has X-Request-Id, every log line has extra.trace_id, and
trace_id() is available anywhere (e.g. show it on a 500 page as a support ref).
Notes
- Propagation: when calling other services, forward the header
(
X-Request-Id: <trace_id()>) so they log under the same id. - Header: defaults to
X-Request-Id(simple correlation). Point it attraceparentif you adopt W3C Trace Context later. - Decoupled:
monologis asuggest— the core (context + interceptor) works without it; the processor only references plain arrays.