Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect traceinfo upon timeout #338

Closed
rightjoin opened this issue May 9, 2020 · 6 comments · Fixed by #342
Closed

incorrect traceinfo upon timeout #338

rightjoin opened this issue May 9, 2020 · 6 comments · Fixed by #342

Comments

@rightjoin
Copy link

When a request timesouts, the data is traceinfo is incorrect.

Often connection time, Response time etc will have max or min possible int64 values

@jeevatkm
Copy link
Member

@rightjoin Thanks for reporting an issue, surely I will look into it.

There is a recent contribution to trace info by @JoaquinJimenezGarcia on #331. Can you please give it a try and share some sample test case for the issue?

@jeevatkm
Copy link
Member

Also, I have created v2.3.0-rc.1, you could try out.

@rightjoin
Copy link
Author

Hi Jeevatkm,

I don't see it resolved in the rc1.

Here is a quick test case:

func TestTraceInfoCorerctOnTimeout(t *testing.T) {

	client := resty.New().EnableTrace()
	client.SetTimeout(10 * time.Millisecond)

	req := client.R()
	req.Get("http://123.123.123.123/")

	trace := req.TraceInfo()

	if trace.ConnTime == math.MinInt64 {
		t.Errorf("Conn time should not be MinInt64 or less than 0")
	}

	if trace.ResponseTime == math.MaxInt64 {
		t.Errorf("Response time should not be MaxInt64")
	}
}

Thanks for the amazing library.

@moorereason
Copy link
Contributor

If the connection times out, how useful is the trace info?

@moorereason
Copy link
Contributor

To be clear, I agree that the trace values are inaccurate in this scenario. I'm just curious what your use case is for using the trace info on failed requests.

@rightjoin
Copy link
Author

There are a number of requests generated for the server, and TraceInfo stats are being aggregated.

moorereason added a commit to moorereason/resty that referenced this issue May 13, 2020
Only calculate TCPConnTime, ConnTime, and ResponseTime for successful
connections.

Fixes go-resty#338
jeevatkm pushed a commit that referenced this issue May 14, 2020
Fixes #338
* Fix TraceInfo on failed connections
* Only calculate TCPConnTime, ConnTime, and ResponseTime for successful
connections
* Sequentially sort clientTrace struct members
* Sort clientTrace struct members based upon the normally trace hook
execution sequence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants