diff --git a/lib/bucketpath.go b/lib/bucketpath.go index d5906c7..527aeef 100644 --- a/lib/bucketpath.go +++ b/lib/bucketpath.go @@ -3,6 +3,7 @@ package lib import ( "strings" "time" + "unicode/utf8" ) const ( @@ -54,6 +55,11 @@ func GetMetricsPath(route string) string { } } + if !utf8.ValidString(path) { + logger.Warn("Non utf-8 path detected, Prometheus only supports utf-8, invalid runes will be replaced with @ in metrics. Path: " + path) + path = strings.ToValidUTF8(path, "@") + } + return path } diff --git a/lib/discord.go b/lib/discord.go index 9d3433b..be64e40 100644 --- a/lib/discord.go +++ b/lib/discord.go @@ -231,6 +231,8 @@ func doDiscordReq(ctx context.Context, path string, method string, body io.ReadC status = "429 Shared" } } + + RequestHistogram.With(map[string]string{"route": route, "status": status, "method": method, "clientId": identifier.(string)}).Observe(elapsed) } return discordResp, err diff --git a/lib/queue_manager.go b/lib/queue_manager.go index a3bb7af..10ec9f4 100644 --- a/lib/queue_manager.go +++ b/lib/queue_manager.go @@ -131,6 +131,10 @@ func (m *QueueManager) calculateRoute(pathHash uint64) string { members := m.orderedClusterMembers count := uint64(len(members)) + if count == 0 { + return "" + } + chosenIndex := pathHash % count addr := m.nameToAddressMap[members[chosenIndex]] if addr == m.localNodeProxyListenAddr {