Skip to content

Commit

Permalink
Log request remote addr in message
Browse files Browse the repository at this point in the history
  • Loading branch information
pkqk committed Nov 19, 2024
1 parent c5bc23a commit 8aceca7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func monitoringMiddleware(h http.Handler) http.Handler {
"request.path": r.URL.Path,
"response.size": m.Written,
})
if r.RemoteAddr != "" {
event.addField("request.ip", r.RemoteAddr)
}

promHTTPRequestCounter.With(prometheus.Labels{
"code": fmt.Sprintf("%dXX", m.Code/100),
Expand Down

0 comments on commit 8aceca7

Please sign in to comment.