Closed frzifus closed 8 months ago
Can you explain ?
Sure, my understanding is that we want to measure the latency of the wrapped handler call and add it to the log line.
The follow up handler is called using c.Next()
. ~To measure the execution we should get the timestamp before and after to calculate the difference.~
~If this middleware is placed before a handler func like this:~
func test(c *gin.Context) {
time.Sleep(time.Minute)
}
~I would expect an execution time of close to 1min.~
~Before this proposed change, it would as minimal as it can be.~
Ups, forget about it. I noticed that start is actually generated at the beginning of the function. :facepalm:
I don't think so ^^
start := time.Now()
// ...
c.Next()
end := time.Now()
latency := end.Sub(start)
Codecov Report
Attention:
2 lines
in your changes are missing coverage. Please review.:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
```diff @@ Coverage Diff @@ ## main #8 +/- ## ===================================== Coverage 0.00% 0.00% ===================================== Files 3 3 Lines 327 328 +1 ===================================== - Misses 327 328 +1 ``` | [Flag](https://app.codecov.io/gh/samber/slog-gin/pull/8/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Berthe) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/samber/slog-gin/pull/8/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Berthe) | `0.00% <0.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Berthe#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/samber/slog-gin/pull/8?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Berthe) | Coverage Δ | | |---|---|---| | [middleware.go](https://app.codecov.io/gh/samber/slog-gin/pull/8?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Berthe#diff-bWlkZGxld2FyZS5nbw==) | `0.00% <0.00%> (ø)` | |:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.