diff --git a/analytics.go b/analytics.go index 11e9a08a89a..30a17fd910a 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 { diff --git a/mw_jwt_test.go b/mw_jwt_test.go index 41753c214e4..31b2e3439ef 100644 --- a/mw_jwt_test.go +++ b/mw_jwt_test.go @@ -687,7 +687,7 @@ func TestJWTSessionExpiresAtValidationConfigs(t *testing.T) { }) t.Run("Expired_token-Before_now-Add_skew--Valid_jwt", func(t *testing.T) { - spec.JWTExpiresAtValidationSkew = 1 + spec.JWTExpiresAtValidationSkew = 2 loadAPI(spec) ts.Run(t, test.TestCase{