redis/go-redis · error

redisotel: %T not supported

Error message

redisotel: %T not supported

What it means

redisotel.InstrumentTracing installs a tracing hook on the client and only supports *redis.Client, *redis.ClusterClient, and *redis.Ring. Any other concrete type — most notably *redis.FailoverClient (sentinel) or a custom UniversalClient — falls into the default case and returns '%T not supported'.

Source

Thrown at extra/redisotel/tracing.go:49

		return nil
	case *redis.ClusterClient:
		rdb.OnNewNode(func(rdb *redis.Client) {
			opt := rdb.Options()
			opts = addServerAttributes(opts, opt.Addr)
			connString := formatDBConnString(opt.Network, opt.Addr)
			rdb.AddHook(newTracingHook(connString, opts...))
		})
		return nil
	case *redis.Ring:
		rdb.OnNewNode(func(rdb *redis.Client) {
			opt := rdb.Options()
			opts = addServerAttributes(opts, opt.Addr)
			connString := formatDBConnString(opt.Network, opt.Addr)
			rdb.AddHook(newTracingHook(connString, opts...))
		})
		return nil
	default:
		return fmt.Errorf("redisotel: %T not supported", rdb)
	}
}

type tracingHook struct {
	conf *config

	spanOpts []trace.SpanStartOption
}

var _ redis.Hook = (*tracingHook)(nil)

func newTracingHook(connString string, opts ...TracingOption) *tracingHook {
	baseOpts := make([]baseOption, len(opts))
	for i, opt := range opts {
		baseOpts[i] = opt
	}
	conf := newConfig(baseOpts...)

View on GitHub (pinned to c5cad058c7)

Solutions

  1. Use one of the supported client types (Client, ClusterClient, Ring)
  2. For failover, add the equivalent tracing hook manually or use a redisotel version that supports FailoverClient
  3. Type-switch on redis.UniversalClient in your own code and instrument the underlying *redis.Client instances
  4. Check rdb != nil before instrumenting

Example fix

// before
var rdb redis.UniversalClient = redis.NewFailoverClient(opt)
redisotel.InstrumentTracing(rdb) // redisotel: *redis.FailoverClient not supported
// after
var rdb redis.UniversalClient = redis.NewClient(&redis.Options{Addr: "localhost:6379"})
redisotel.InstrumentTracing(rdb)
Defensive patterns

Strategy: type-guard

Type guard

func tracingSupported(rdb redis.UniversalClient) bool {
	switch rdb.(type) {
	case *redis.Client, *redis.ClusterClient, *redis.Ring:
		return true
	default:
		return false
	}
}

Try / catch

if err := redisotel.InstrumentTracing(rdb); err != nil {
	if strings.Contains(err.Error(), "not supported") {
		log.Printf("tracing skipped for %T", rdb)
	}
}

Prevention

When it happens

Trigger: Calling InstrumentTracing with a Sentinel failover client, a nil client, or a custom type implementing redis.UniversalClient.

Common situations: Sentinel-based deployments instrumented with redisotel; generic code taking redis.UniversalClient and instrumenting blindly; mocks in tests.

Related errors


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/852f32a9ce6063d5. Report an issue: GitHub.