-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DDO-3268] Improve logging/metrics for Gin responses #338
Conversation
No API changes detected |
Codecov Report
@@ Coverage Diff @@
## main #338 +/- ##
==========================================
- Coverage 63.23% 63.21% -0.02%
==========================================
Files 147 147
Lines 8671 8683 +12
==========================================
+ Hits 5483 5489 +6
- Misses 2813 2819 +6
Partials 375 375
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, otherwise looks straightforward to me!
output.FormatCaller = func(i interface{}) string { | ||
if i == nil { | ||
return "" | ||
} else { | ||
return fmt.Sprintf("%-50s |", strings.TrimPrefix(fmt.Sprintf("%s", i), "/build/sherlock/internal")) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious what this is for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Adds metrics for response latency/count, by Gin's matched route.
Also touches up logging. Normal internal log messages are staying the same, but the Gin ones now take full advantage of Zerolog's JSON fields. Things like the status code, client IP, latency, etc are no longer logged in just a big string, they're logged as fields with Zerolog.
This makes the Gin logging slightly worse locally, but way, way better through GCP. It's a balancing act and I think the Gin logs are primarily useful through GCP anyway, so I think it's okay. This also helps avoid logging things to console that we only need on GCP, like the client IP.
Before:
After:
Testing
Screenshots above; visited /metrics to validate that part.
Risk
Very low, no functionality changing, just logs