tcnksm / go-httpstat

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

Proposed code based on fix to issue #13 #14

Closed JoseIgnacioTamayo closed 5 years ago

JoseIgnacioTamayo commented 7 years ago

Proposing some changes in the library, to correct some behaviour seen in Go1.8

When we started using the library with Go1.8, the contentTransfer() and Total() methods returned out of order values. So we propose to simplify the internals of the struct Result, depend only on the End() method.

Also some test were added to test for Client that has a very simple Transport, no Dialer nor DialerContext, and running in go 1.8. This was our case and it was better to have it tested here.

The tests are passing:

go test -v -parallel=4 github.com/tcnksm/go-httpstat === RUN TestHTTPStat_HTTPS DNSDone tcpDone tlsDone GotConn serverStart --- PASS: TestHTTPStat_HTTPS (0.71s) === RUN TestHTTPStat_HTTP DNSDone tcpDone GotConn serverStart --- PASS: TestHTTPStat_HTTP (0.02s) === RUN TestHTTPStat_KeepAlive_HTTPS GotConn >>>> Only cached connection prints serverStart >>>> Only cached connection prints --- PASS: TestHTTPStat_KeepAlive_HTTPS (1.17s) === RUN TestHTTPStat_KeepAlive_HTTP GotConn >>>> Only cached connection prints serverStart >>>> Only cached connection prints --- PASS: TestHTTPStat_KeepAlive_HTTP (0.02s) === RUN TestHTTPStat_beforeGO17 tlsDone >>>> No DNS nor TCP stages GotConn serverStart GotConn >>>> Cached connetion serverStart --- PASS: TestHTTPStat_beforeGO17 (0.40s) === RUN TestHTTPStat_NoDialer_HTTPS DNSDone tcpDone tlsDone GotConn serverStart GotConn >>>> Cached connetion serverStart >>>> Cached connetion --- PASS: TestHTTPStat_NoDialer_HTTPS (1.25s) === RUN TestHTTPStat_NoDialer_HTTP DNSDone tcpDone GotConn serverStart GotConn >>>> Cached connetion serverStart >>>> Cached connetion --- PASS: TestHTTPStat_NoDialer_HTTP (0.02s) === RUN TestTotal_Zero --- PASS: TestTotal_Zero (0.00s) === RUN TestHTTPStat_Formatter --- PASS: TestHTTPStat_Formatter (0.00s) PASS ok github.com/tcnksm/go-httpstat 3.593s

JoseIgnacioTamayo commented 5 years ago

Cancelling this pull request to make a better one from the current master branch