Monitoring Go Redis Performance and Errors

OpenTelemetry Tracing

go-redis relies on OpenTelemetry to monitor database performance and errors using distributed tracingopen in new window and metricsopen in new window.

OpenTelemetryopen in new window is a vendor-neutral API for distributed traces and metrics. It specifies how to collect and send telemetry data to backend platforms. It means that you can instrument your application once and then add or change vendors (backends) as required.

OpenTelemetry instrumentation

go-redis comes with an OpenTelemetry instrumentation called redisotelopen in new window that is distributed as a separate module:

go get

To instrument Redis client, you need to add the hook provided by redisotel:

import (

rdb := redis.NewClient(&redis.Options{...})


For Redis Cluster and Ring you need to instrument each node separately:

rdb := redis.NewClusterClient(&redis.ClusterOptions{
    // ...

    NewClient: func(opt *redis.Options) *redis.Client {
        node := redis.NewClient(opt)
        return node


To make tracing work, you must pass the active trace contextopen in new window to go-redis commands, for example:

ctx := req.Context()
val, err := rdb.Get(ctx, "key").Result()

Trace example

As expected, redisotel creates spansopen in new window for processed Redis commands and records any errors as they occur. Here is how the collected information is displayed at Uptrace tracing toolopen in new window:

Redis trace

You can find a runnable example at GitHubopen in new window.

Monitoring Redis Server performance

To monitor Redis Server performance, see Monitoring Redis Performance using OpenTelemetryopen in new window.

See also