go-httpstat icon indicating copy to clipboard operation
go-httpstat copied to clipboard

result.ContentTransfer freezed value since update Go1.8

Open bennneuh opened this issue 7 years ago • 11 comments

Hello,

Thanks again for the update in 1.8

I have a small issue since the update. I'm not sure it's linked to the update, but i don't understand.

i always have the same fix value for ContentTransfert:

with:

end := time.Now()
fmt.Println("result.ContentTransfer(end) ", result.ContentTransfer(end))

The result is always: result.ContentTransfer(end) 2562047h47m16.854775807s

Thanks for your help,

Benoît

bennneuh avatar Apr 11 '17 12:04 bennneuh

FYI i have tested in the example "_example" by adding: ` end := time.Now()

log.Printf("YO Name Lookup:    %d ms", int(result.NameLookup/time.Millisecond))
log.Printf("YO Connect:        %d ms", int(result.Connect/time.Millisecond))
log.Printf("YO Start Transfer: %d ms", int(result.StartTransfer/time.Millisecond))
log.Printf("YO Total:          %d ms", int(result.Total(end)/time.Millisecond))`

i have the same issue.

But no issue with fmt.Printf("%+v\n", result)

bennneuh avatar Apr 12 '17 09:04 bennneuh

For the moment i have fixed the issue like that:

`func (r *Result) ContentTransfer(t time.Time) time.Duration { //return t.Sub(r.t4) return r.contentTransfer }

// Total returns the duration of total http request. // It is from dns lookup start time to the given time. The // time must be time after read body (go-httpstat can not detect that time). func (r *Result) Total(t time.Time) time.Duration { //return t.Sub(r.t0) return r.total }`

But i'm sure it's not the best way :) because the "t" is useless and i need to run result.End(end) before.

bennneuh avatar Apr 12 '17 09:04 bennneuh

On yanc0/beeping we locked this package on commit fae40520f4ba0a112874d1f0deb9498ebb2198cb before the regression.


[[dependencies]]
  name = "github.com/tcnksm/go-httpstat"
  revision = "fae40520f4ba0a112874d1f0deb9498ebb2198cb"

yanc0 avatar May 01 '17 14:05 yanc0

Also facing this issue.

Its constantly returning 9223372036854 ms for me.

Printing out results gives me TLSHandshake: 193 ms, ServerProcessing: 100 ms, ContentTransfer: - ms, so seems to be not recording anything.

davinchia avatar May 08 '17 20:05 davinchia

Up :)

bennneuh avatar Jun 26 '17 21:06 bennneuh

I was googling for 2562047h47m16.854775807s and found this post (we also have a problem with dates ethereumproject/go-ethereum#366).

The root of the problem is: time difference is calculated against zero value of time.Time. This causes overflow intime.Sub, which causes returning maxDuration constant.

The value for this constant is exactly 2562047h47m16.854775807s or 9223372036854 or 1<<63 -1 (nanoseconds).

tzdybal avatar Nov 09 '17 20:11 tzdybal

Yes, looks like the variables t0-t4 are no longer populated but they are still used by ContentTransfer and Total methods, resulting the duration since zero time. But I only had this issue because I was using dep tool with the latest release, switching to master solved this issue.

rif avatar Nov 21 '17 07:11 rif

I also found this issue when using dep, in my case it's resolving to the latest release (v0.2.0).

Probably adding a new release with the corresponding bump in the semver would fix this for other dep users?

anthonynsimon avatar May 02 '18 13:05 anthonynsimon

Same problem here. Fixed at some older revision for now.

johannesfritsch avatar Jun 22 '18 14:06 johannesfritsch

using go get github.com/tcnksm/go-httpstat@master fixed it for me.

vincentvdk avatar May 29 '20 14:05 vincentvdk

using go get github.com/tcnksm/go-httpstat@master fixed it for me.

Yep this worked for me. I'm using go v1.17

teja42 avatar Dec 24 '21 07:12 teja42