1
0
Fork 0
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:
Henrik Hautakoski 2023-02-06 13:02:08 +01:00
parent 12bd16399b
commit b815bcee44
No known key found for this signature in database
GPG key ID: 217490840C18A5D9

View file

@ -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)