Skip to content

Commit

Permalink
replace Contains with CutPrefix
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmir committed Sep 9, 2024
1 parent 0e7b90f commit 29016a2
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions redis/db/redisbp/monitored_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ func getDeploymentType(addr string) string {
func getTargetCluster(addr string) string {
if strings.Contains(addr, "cache.amazonaws") {
return ""
} else {
// redis-<cluster name>.<vpc>.<region>.<postfix>.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-<cluster name>.<vpc>.<region>.<postfix>.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
Expand Down

0 comments on commit 29016a2

Please sign in to comment.