{"id":"7817f16dee546005","repo":"go-redis/redis","slug":"redisotel-t-not-supported","errorCode":null,"errorMessage":"redisotel: %T not supported","messagePattern":"redisotel: %T not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extra/redisotel/metrics.go","lineNumber":55,"sourceCode":"\t\t\tmetric.WithInstrumentationVersion(\"semver:\"+redis.Version()),\n\t\t)\n\t}\n\tif conf.poolName == \"\" {\n\t\tswitch rdb := rdb.(type) {\n\t\tcase *redis.Client:\n\t\t\tconf.poolName = rdb.Options().Addr\n\t\tcase *redis.ClusterClient:\n\t\t\tfor _, addr := range rdb.Options().Addrs {\n\t\t\t\tconf.poolName = addr\n\t\t\t\tbreak\n\t\t\t}\n\t\tcase *redis.Ring:\n\t\t\tfor _, addr := range rdb.Options().Addrs {\n\t\t\t\tconf.poolName = addr\n\t\t\t\tbreak\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"redisotel: %T not supported\", rdb)\n\t\t}\n\t}\n\tconf.attrs = append(conf.attrs, attribute.String(\"pool.name\", conf.poolName))\n\n\tvar state *metricsState\n\tif conf.closeChan != nil {\n\t\tstate = &metricsState{\n\t\t\tregistrations: make([]metric.Registration, 0),\n\t\t\tclosed:        false,\n\t\t\tmutex:         sync.Mutex{},\n\t\t}\n\n\t\tgo func() {\n\t\t\t<-conf.closeChan\n\n\t\t\tstate.mutex.Lock()\n\t\t\tstate.closed = true\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/extra/redisotel/metrics.go#L37-L73","documentation":"Returned by InstrumentMetrics (extra/redisotel/metrics.go:55) when the passed redis.UniversalClient is not one of the supported concrete types (*redis.Client, *redis.ClusterClient, *redis.Ring) and no explicit poolName was configured. The type switch falls through to the default case because the client wrapper type is unrecognized.","triggerScenarios":"Calling redisotel.InstrumentMetrics with a client type other than *redis.Client, *redis.ClusterClient, or *redis.Ring without setting the WithMetricsDestinationAddr/WithPoolName option to pre-populate conf.poolName.","commonSituations":"Passing a redis.UniversalClient that wraps one of the supported types but is itself a different concrete type; using a custom client implementation that satisfies the UniversalClient interface but is not one of the three built-in types; wrapping the client in a decorator or mock.","solutions":["Pass the concrete *redis.Client, *redis.ClusterClient, or *redis.Ring directly to InstrumentMetrics","Use the WithPoolName option to pre-set conf.poolName so the type switch is skipped entirely","If using a UniversalClient wrapper, unwrap it to the underlying concrete client before passing it to InstrumentMetrics"],"exampleFix":"// before - passing a UniversalClient wrapper\nvar rdb redis.UniversalClient = getUniversalClient()\nerr := redisotel.InstrumentMetrics(rdb)\n// returns: redisotel: *universalClient not supported\n\n// after - pass the concrete type, or set poolName explicitly\nerr := redisotel.InstrumentMetrics(rdb.(*redis.Client))\n// or:\nerr := redisotel.InstrumentMetrics(rdb, redisotel.WithPoolName(\"my-pool\"))","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Check the concrete client type before calling InstrumentMetrics\nswitch rdb.(type) {\ncase *redis.Client, *redis.ClusterClient, *redis.Ring:\n    // supported - proceed\ndefault:\n    log.Fatalf(\"redisotel.InstrumentMetrics does not support client type %T; unwrap or set poolName\", rdb)\n}","tryCatchPattern":"if err := redisotel.InstrumentMetrics(rdb, redisotel.WithPoolName(\"my-pool\")); err != nil {\n    if strings.Contains(err.Error(), \"not supported\") {\n        log.Errorf(\"unsupported client type %T; pass *redis.Client/*ClusterClient/*Ring or set poolName\", rdb)\n    }\n}","preventionTips":["Pass concrete client types (*redis.Client, *redis.ClusterClient, *redis.Ring) to InstrumentMetrics, not wrappers","Use the WithPoolName option to bypass the type switch when passing custom client types","Unwrap UniversalClient to its underlying concrete client before instrumentation"],"tags":["otel","redisotel","metrics","client-type","universal-client"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}