asynqx

package
v1.15.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package asynqx carries OpenTelemetry trace context across the asynq boundary. asynq has no message headers, so the producer wraps the task payload in an envelope holding the W3C trace context, and the worker-side middleware unwraps it, resumes the producer's trace and opens a consumer span around the handler. Payloads without an envelope (older in-flight tasks, traceless producers, scheduler ticks) pass through untouched and get a root span, so every task execution logs a trace id either way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware() asynq.MiddlewareFunc

Middleware resumes the producer's trace from the payload envelope (when present), hands the handler the unwrapped payload, and records the task execution as a consumer span.

func Wrap

func Wrap(ctx context.Context, task *asynq.Task) *asynq.Task

Wrap returns a task whose payload carries ctx's trace context; without an active span (or with a payload the envelope cannot hold) it returns the task unchanged.

Types

type Client

type Client struct {
	*asynq.Client
}

Client wraps *asynq.Client so EnqueueContext stamps the caller's trace context onto the task. Wrapping rebuilds the task, which drops options embedded at NewTask time — pass options to EnqueueContext instead. The plain Enqueue promotes from the inner client untraced (it has no context to read).

func NewClient

func NewClient(client *asynq.Client) *Client

func (*Client) EnqueueContext

func (c *Client) EnqueueContext(ctx context.Context, task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL