diff --git a/redis/db/redisbp/monitored_client.go b/redis/db/redisbp/monitored_client.go index 601d21d9c..32d540b39 100644 --- a/redis/db/redisbp/monitored_client.go +++ b/redis/db/redisbp/monitored_client.go @@ -36,19 +36,19 @@ func getDeploymentType(addr string) string { func getTargetCluster(addr string) string { if strings.Contains(addr, "cache.amazonaws") { return "" - } else { - // redis-....net:6379 - tokens := strings.Split(addr, ".") - if len(tokens) != 5 { - return "" - } - - if strings.Contains(tokens[0], "redis-") && len(tokens[0]) > 6 { - return tokens[0][6:] - } + } + // redis-....net:6379 + tokens := strings.Split(addr, ".") + if len(tokens) != 5 { return "" } + + if name, found := strings.CutPrefix(tokens[0], "redis-"); found { + return name + } + + return "" } // NewMonitoredClient creates a new *redis.Client object with a redisbp.SpanHook