Skip to main content

nexus-observability-worker-pool

Worker-pool observability — a tracing decorator for WorkerTransport that propagates trace context across worker-thread boundaries and records transport metrics. The receiving actor can open a Consumer span from the injected metadata, completing the distributed trace.

Install

terminal
composer require nexus-actors/observability-worker-pool

What's in this package

ClassPurpose
TracingWorkerTransportDecorator for WorkerTransport: opens a Producer span on send(), injects the span context into the envelope metadata, and records nexus.worker_pool.messages.sent and nexus.worker_pool.send.duration

Quick example

src/WorkerPool/Bootstrap.php
use Monadial\Nexus\Observability\WorkerPool\TracingWorkerTransport;

// $innerTransport is a WorkerTransport (e.g. ThreadQueueTransport)
$transport = new TracingWorkerTransport($innerTransport, $obs);

The decorator calls the inner transport directly when $obs->isEnabled() returns false. Transport errors always propagate; telemetry errors are silently ignored.

Emitted spans and metrics

NameKindDimensions
worker.sendProducer spanmessaging.operation, messaging.system, nexus.actor.path, nexus.worker.target
nexus.worker_pool.messages.sentCounternexus.worker.target
nexus.worker_pool.send.durationHistogram (s)nexus.worker.target

Trace context is injected into Envelope::$metadata as W3C traceparent/tracestate headers so the receiving worker can extract the parent span and open a Consumer span, linking the cross-thread hops in a single trace.

See also