mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-06-16 04:44:55 +02:00
internal/server/server.go: Adding request duration to log row.
This commit is contained in:
parent
12bd16399b
commit
b815bcee44
1 changed files with 4 additions and 0 deletions
|
|
@ -108,10 +108,14 @@ func (s *Server) OnTraffic(c gnet.Conn) gnet.Action {
|
|||
// gnet library does not like blocking calls.
|
||||
// as we do a blocking http call here, we need to wrap it in a goroutine.
|
||||
go func() {
|
||||
t := time.Now()
|
||||
status, msg := healthCheckApi.Call()
|
||||
req_time := time.Since(t)
|
||||
|
||||
params := api.LogParams{}
|
||||
params.Add("status", strings.TrimSpace(status.String()))
|
||||
params.Add("duration", req_time)
|
||||
params.Add("duration_us", req_time.Microseconds())
|
||||
|
||||
if msg != "OK" && len(msg) > 0 {
|
||||
params.Add("error", msg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue