[FEATURE REQUEST] Support headers in Task metadata (e.g., OpenTelemetry context propagation)
Currently, there is no standardized way to attach metadata (such as headers) directly to an asynq.Task. When tracing distributed systems with OpenTelemetry, propagating context across async job queues requires manually embedding tracing context into the task payload JSON or using workaround wrappers. This adds boilerplate and degrades payload clarity.
I'd like asynq.Task to support headers/metadata (e.g., key-value pairs like http.Header or map[string]string).
This will allow:
- Easy propagation of OpenTelemetry trace contexts (W3C
traceparent/tracestate). - Attaching cross-cutting operational metadata (e.g., request IDs, tenant IDs, correlation IDs) without bloating or modifying the application-level payload body.
Ideally, headers should be accessible on both the producer side when building a task and on the consumer side within the handler/middleware context.
- Embedding metadata inside task payloads: Forces application logic to parse/unwrap tracing fields from every payload, mixing transport-level metadata with domain data.
- Custom payload wrappers: Requires wrapping all task structures in a generic envelope struct containing metadata, which introduces unnecessary payload structure overhead.
Context propagation via task headers is a common feature in distributed messaging and queue systems (such as Kafka headers, RabbitMQ headers). Adding native header support to Asynq would greatly simplify integration with modern observability and telemetry stacks.
Source: hibiken/asynq