Skip to content

Tracing

Conflux propagates trace context through all execution boundaries using the W3C Trace Context standard and the OpenTelemetry PHP SDK.

traceparent format

The traceparent header uses the following format:

00-{trace-id}-{parent-id}-{flags}
Field Length Description
version 2 hex chars Always 00 (current W3C spec version)
trace-id 32 hex chars Unique ID for the entire distributed trace
parent-id 16 hex chars ID of the calling span
flags 2 hex chars 01 = sampled, 00 = not sampled

Example: 00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01

HTTP requests

Incoming: SetSpanContext middleware runs on every request. If a traceparent header is present, a child span is created from the upstream context. If absent, a new root span with a fresh trace ID is created.

Response headers set:

Header Value Purpose
traceparent Full W3C traceparent of the created span Allows callers to correlate their trace with Conflux's
X-Request-ID Span ID (16 hex chars) Backward compatibility

Queue jobs

When a job is dispatched, _traceparent is injected into the job payload from the active span context. When the worker picks up the job, the trace context is restored and a child span is created.

Payload key: _traceparent (W3C traceparent string)

If no span is active at dispatch time (e.g. dispatched from a CLI command with no active span), _traceparent is omitted and the job starts a fresh trace.

CLI commands

When an Artisan command starts, a root span with a fresh trace ID is created. This covers both scheduled commands and manually invoked ones.

Outgoing HTTP requests

All outgoing HTTP requests made via Laravel's Http facade automatically receive a traceparent header injected from the active span context. This propagates the trace into downstream services.

Log context

Every log entry written during a traced request, job, or command includes:

Field Value
trace_id 32-char hex trace ID
span_id 16-char hex span ID

Resource attributes

Every exported span carries a service.name resource attribute. Per the OTel spec, an SDK falls back to unknown_service:{process.executable.name} (e.g. unknown_service:php) if this isn't set explicitly. Conflux sets it via config/telemetry.php's service_name key (env: OTEL_SERVICE_NAME, default conflux).

Implementation

Class Responsibility
App\Providers\TelemetryServiceProvider Registers TracerProvider and TracerInterface as singletons, sets the service.name resource attribute
App\Http\Middleware\SetSpanContext HTTP span lifecycle — extract, create, activate, set response headers
App\Providers\AppServiceProvider Queue, CLI, and outgoing HTTP propagation
App\Logging\TraceContextProcessor Monolog processor — injects trace_id and span_id into every log record