Skip to content

Commit

Permalink
add leading backslash to path if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dencoded authored and buger committed Aug 9, 2018
1 parent 000bfe4 commit b4469d4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"net"
"strings"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b4469d4

Please sign in to comment.