Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route to request log #2162

Merged
merged 2 commits into from Dec 4, 2022
Merged

Conversation

k-yomo
Copy link
Contributor

@k-yomo k-yomo commented Apr 26, 2022

This PR adds route to tags used for request logging to be able to log the route pattern.
There is a usecase that we want to log the route to aggregate the request in monitoring.

@lammel
Copy link
Contributor

lammel commented Nov 30, 2022

A way of adding custom information for logging has been prepared by using a ${custom} tag with PR #2341

@aldas What are your thoughts on this, personally I find that quite useful to show a matching route for a request. Would have needed that myself a few times.

@lammel lammel requested a review from aldas November 30, 2022 12:50
@@ -91,17 +91,17 @@ func TestLoggerTemplate(t *testing.T) {
e.Use(LoggerWithConfig(LoggerConfig{
Format: `{"time":"${time_rfc3339_nano}","id":"${id}","remote_ip":"${remote_ip}","host":"${host}","user_agent":"${user_agent}",` +
`"method":"${method}","uri":"${uri}","status":${status}, "latency":${latency},` +
`"latency_human":"${latency_human}","bytes_in":${bytes_in}, "path":"${path}", "referer":"${referer}",` +
`"latency_human":"${latency_human}","bytes_in":${bytes_in}, "path":"${path}", "route":"${route}" "referer":"${referer}",` +
Copy link
Contributor

@aldas aldas Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be pedantic :) , comma is missing between route and referer. otherwise this is OK PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh thanks for the good catch, fixed🙏
10a35c5

@k-yomo k-yomo requested a review from aldas December 4, 2022 11:37
@codecov
Copy link

codecov bot commented Dec 4, 2022

Codecov Report

Base: 92.20% // Head: 92.69% // Increases project coverage by +0.49% 🎉

Coverage data is based on head (10a35c5) compared to base (572466d).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2162      +/-   ##
==========================================
+ Coverage   92.20%   92.69%   +0.49%     
==========================================
  Files          37       37              
  Lines        3090     4462    +1372     
==========================================
+ Hits         2849     4136    +1287     
- Misses        151      238      +87     
+ Partials       90       88       -2     
Impacted Files Coverage Δ
middleware/logger.go 85.10% <100.00%> (-2.17%) ⬇️
middleware/recover.go 81.63% <0.00%> (-3.37%) ⬇️
middleware/compress.go 81.15% <0.00%> (-2.85%) ⬇️
middleware/body_dump.go 90.47% <0.00%> (-2.12%) ⬇️
middleware/request_id.go 83.87% <0.00%> (-1.85%) ⬇️
middleware/key_auth.go 93.42% <0.00%> (-1.50%) ⬇️
middleware/static.go 68.80% <0.00%> (-1.20%) ⬇️
middleware/slash.go 90.62% <0.00%> (-0.68%) ⬇️
bind.go 88.88% <0.00%> (-0.59%) ⬇️
... and 31 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@aldas aldas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lammel lammel merged commit 135c511 into labstack:master Dec 4, 2022
@k-yomo k-yomo deleted the add-route-to-request-log branch December 11, 2022 16:57
@aldas aldas mentioned this pull request Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants