Skip to content

Commit

Permalink
feat: make user-agent logging more loki-friendly.
Browse files Browse the repository at this point in the history
  • Loading branch information
clambin committed Jan 5, 2025
1 parent 9419da2 commit c87f6c3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/server/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func (r *RejectedRequest) LogValue() slog.Value {
return slog.GroupValue(
slog.String("method", r.Method),
slog.String("url", r.URL.String()),
slog.String("user-agent", ((*http.Request)(r)).UserAgent()),
slog.String("user_agent", ((*http.Request)(r)).UserAgent()),
)
}
2 changes: 1 addition & 1 deletion internal/server/logging/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ func TestRejectedRequest_LogValue(t *testing.T) {
r, _ := http.NewRequest(http.MethodGet, "https://example.com/", nil)
r.Header.Add("User-Agent", "foo")

assert.Equal(t, "[method=GET url=https://example.com/ user-agent=foo]", (*RejectedRequest)(r).LogValue().String())
assert.Equal(t, "[method=GET url=https://example.com/ user_agent=foo]", (*RejectedRequest)(r).LogValue().String())
}

0 comments on commit c87f6c3

Please # to comment.