Monitoring Tasks Performance and Errors

What is OpenTelemetry?

taskq uses OpenTelemetry to monitor performance and errors using distributed tracingopen in new window and metricsopen in new window.

OpenTelemetryopen in new window is a vendor-neutral standard that allows you to collect and export tracesopen in new window, logsopen in new window, and metricsopen in new window.

OpenTelemetry is available for most programming languages and allows to send performance data to any tracing toolopen in new window of your choice.

OpenTelemetry instrumentation

First, you need to install taskqotel module:

go get github.com/vmihailenco/taskq/extra/taskqotel/v3

Then, install the hook provided by the module:

import "github.com/vmihailenco/taskq/extra/taskqotel/v3"

consumer := queue.Consumer()
consumer.AddHook(taskqotel.NewHook())

You can install the hook for all queues created by the factory like this:

factory.Range(func(q taskq.Queue) bool {
    consumer := q.Consumer()
    consumer.AddHook(taskqotel.NewHook())
    return true
})

Once hook is installed, just start the consumer as usually:

if err := consumer.Start(ctx); err != nil {
    panic(err)
}

Uptrace

Uptrace is an open source APMopen in new window for OpenTelemetry that supports distributed tracing, metrics, and logs. You can use it to monitor applications and troubleshoot issues.

Uptrace Overview

Uptrace comes with an intuitive query builder, rich dashboards, alerting rules, notifications, and integrations for most languages and frameworks.

Uptrace can process billions of spans and metrics on a single server and allows you to monitor your applications at 10x lower cost.

In just a few minutes, you can try Uptrace by visiting the cloud demoopen in new window (no login required) or running it locally with Dockeropen in new window. The source code is available on GitHubopen in new window.

Prometheus

You can send OpenTelemetry metrics to Prometheus using OpenTelemetry Prometheus exporteropen in new window.

See also