tcnksm / go-httpstat

Tracing golang HTTP request latency
MIT License
423 stars 72 forks source link

Wrong sum if all values are zero #8

Closed dewey closed 7 years ago

dewey commented 7 years ago

I think I found a small bug in the code that does the calculations for the total amount of time. If you set all values to 0 (for example if there's an outtage) the result is 9223372036854 instead of 0.

result := httpstat.Result{
        DNSLookup:        0.0,
    TCPConnection:    0.0,
    TLSHandshake:     0.0,
    ServerProcessing: 0.0,
    NameLookup:       0.0,
    Connect:          0.0,
    Pretransfer:      0.0,
    StartTransfer:    0.0,
}
result.End(time.Now())

If you print result:

TLSHandshake: 0 ms, Total: 9223372036854 ms, StartTransfer: 0 ms, DNSLookup: 0 ms, TCPConnection: 0 ms, ServerProcessing: 0 ms, ContentTransfer: 9223372036854 ms, NameLookup: 0 ms, Connect: 0 ms, Pretransfer: 0 ms
tcnksm commented 7 years ago

Thank you for reporting issue.

Fixed it on https://github.com/tcnksm/go-httpstat/pull/9