From b4469d4720099c74ecec5a2542ee5f5ee1c2ae37 Mon Sep 17 00:00:00 2001 From: dencoded Date: Fri, 3 Aug 2018 00:09:29 -0400 Subject: [PATCH] add leading backslash to path if needed --- analytics.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/analytics.go b/analytics.go index 11e9a08a89ac..30a17fd910a9 100644 --- a/analytics.go +++ b/analytics.go @@ -3,6 +3,7 @@ package main import ( "fmt" "net" + "strings" "sync" "sync/atomic" "time" @@ -269,6 +270,14 @@ func (r *RedisAnalyticsHandler) recordWorker() { record.Tags = append(record.Tags, "api-"+record.APIID) + // fix paths in record as they might have omitted leading "/" + if !strings.HasPrefix(record.Path, "/") { + record.Path = "/" + record.Path + } + if !strings.HasPrefix(record.RawPath, "/") { + record.RawPath = "/" + record.RawPath + } + if encoded, err := msgpack.Marshal(record); err != nil { log.WithError(err).Error("Error encoding analytics data") } else {