Skip to content

Commit

Permalink
logtastic: truncate url to 1024 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Jun 10, 2024
1 parent 025f764 commit 51cde15
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions logtastic/logtastic.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
throttleTimeout = time.Second * 15

kPleaseStop = "please-stop"
kMaxURLLen = 1024
)

var (
Expand Down Expand Up @@ -208,6 +209,10 @@ func LogHit(r *http.Request, code int, size int64, dur time.Duration) {
}
m := map[string]interface{}{}
httputil.GetRequestInfo(r, m, "")
uri := m["url"].(string)
if len(uri) > kMaxURLLen {
m["url"] = uri[:kMaxURLLen]
}
m["dur_ms"] = float64(dur) / float64(time.Millisecond)
m["status"] = code
m["size"] = size
Expand Down

0 comments on commit 51cde15

Please sign in to comment.