-
Notifications
You must be signed in to change notification settings - Fork 1
Add OpenTelemetry tracing for task dispatch and execution #56
Description
Summary
Instrument task dispatch and execution with OpenTelemetry tracing. Create spans on both the client side (WorkerProxy.dispatch) and worker side (WorkerService.dispatch) so users get end-to-end visibility into dispatch latency, nested task chains, and errors without writing custom instrumentation.
Use a no-op tracer by default so there is zero overhead until the user configures an OTel exporter. No new dependencies required — opentelemetry-api provides the tracer interface and is a no-op when no SDK is installed. Gate the opentelemetry-api dependency behind a telemetry extra.
Motivation
Users currently have no built-in way to monitor dispatch latency, trace nested task chains, or correlate errors across workers. OpenTelemetry is the standard for this and fits Wool's philosophy of integrating with purpose-built tools rather than reinventing them.
The existing Task dataclass already carries the right data for span attributes: task ID, tag, caller (parent task UUID), worker address, and timeout. The caller field maps directly to OTel's parent-child span model, giving nested routine chains automatic trace trees.
Affected code
wool/src/wool/runtime/worker/proxy.py— client-side dispatch spanwool/src/wool/runtime/worker/service.py— worker-side execution spanwool/src/wool/runtime/routine/task.py— span attribute sourcewool/pyproject.toml— optionalopentelemetry-apidependency