From 535be51cd15e1c4aafc224ddab4eb7afff18d54d Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Fri, 2 Sep 2022 15:10:57 +0200 Subject: [PATCH] fix(tracex): use HTTP transaction end time for `t` (#925) This issue was mentioned in https://github.com/ooni/probe/issues/2137. I double checked the spec and this field is not mentioned. We will update it when we do https://github.com/ooni/probe/issues/2238. --- internal/tracex/http.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/tracex/http.go b/internal/tracex/http.go index 6f4d62b..3296218 100644 --- a/internal/tracex/http.go +++ b/internal/tracex/http.go @@ -62,10 +62,6 @@ type HTTPTransportSaver struct { // body snapshot that we collect along with the HTTP round trip. func (txp *HTTPTransportSaver) RoundTrip(req *http.Request) (*http.Response, error) { - // TODO(bassosimone): we're currently using the started time for - // the transaction done event, which contrasts with what we do for - // every other event. What does the spec say? - started := time.Now() txp.Saver.Write(&EventHTTPTransactionStart{&EventValue{ HTTPRequestHeaders: httpCloneRequestHeaders(req), @@ -79,9 +75,12 @@ func (txp *HTTPTransportSaver) RoundTrip(req *http.Request) (*http.Response, err HTTPMethod: req.Method, HTTPURL: req.URL.String(), Transport: txp.HTTPTransport.Network(), - Time: started, + Time: time.Time{}, // see below } - defer txp.Saver.Write(&EventHTTPTransactionDone{ev}) + defer func() { + ev.Time = time.Now() // https://github.com/ooni/probe/issues/2137 + txp.Saver.Write(&EventHTTPTransactionDone{ev}) + }() resp, err := txp.HTTPTransport.RoundTrip(req)