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.
This commit is contained in:
Simone Basso 2022-09-02 15:10:57 +02:00 committed by GitHub
parent 1153850aca
commit 535be51cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,10 +62,6 @@ type HTTPTransportSaver struct {
// body snapshot that we collect along with the HTTP round trip. // body snapshot that we collect along with the HTTP round trip.
func (txp *HTTPTransportSaver) RoundTrip(req *http.Request) (*http.Response, error) { 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() started := time.Now()
txp.Saver.Write(&EventHTTPTransactionStart{&EventValue{ txp.Saver.Write(&EventHTTPTransactionStart{&EventValue{
HTTPRequestHeaders: httpCloneRequestHeaders(req), HTTPRequestHeaders: httpCloneRequestHeaders(req),
@ -79,9 +75,12 @@ func (txp *HTTPTransportSaver) RoundTrip(req *http.Request) (*http.Response, err
HTTPMethod: req.Method, HTTPMethod: req.Method,
HTTPURL: req.URL.String(), HTTPURL: req.URL.String(),
Transport: txp.HTTPTransport.Network(), 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) resp, err := txp.HTTPTransport.RoundTrip(req)