sosedoff / pgweb

Cross-platform client for PostgreSQL databases
https://sosedoff.github.io/pgweb
MIT License
8.53k stars 724 forks source link

wrong duration_ms round #671

Closed Quake4 closed 1 year ago

Quake4 commented 1 year ago
time="2023-04-21T10:05:43+03:00" level=info msg=http_request duration=3.5987ms duration_ms=3 method=GET path=/api/schemas remote_addr=127.0.0.1 status=200
time="2023-04-21T10:05:44+03:00" level=info msg=http_request duration=47.5313ms duration_ms=47 method=GET path=/api/objects remote_addr=127.0.0.1 status=200

must be a 4 and 48 ms. duration=3.5987ms: duration_ms=3 => duration_ms=4 duration=47.5313ms: duration_ms=47 => duration_ms=48

sosedoff commented 1 year ago

See https://github.com/sosedoff/pgweb/blob/master/pkg/api/logger.go#L60-L61, its the golang stdlib: https://pkg.go.dev/time#Duration.Milliseconds

Quake4 commented 1 year ago

is you joke?

package main

import (
    "fmt"
    "time"
)

func main() {
    d, _ := time.ParseDuration("1s.918573645s")
    fmt.Printf("d.Round(%s) = %d\n", time.Millisecond, d.Round(time.Millisecond).Milliseconds())
}
sosedoff commented 1 year ago

What is your point? Pgweb is not a type of application where reporting a difference in 1ms matters.

Quake4 commented 1 year ago

image Why not display the correct number?

Quake4 commented 1 year ago

Pgweb is not a type of application where reporting a difference in 1ms matters.

Let the application show correctly, and the user will decide what this value means.