feat(measurexlite): add T0 and TransactionID (#879)

The T0 field is the moment when we started collecting data, while T
is the moment when we finished collecting data.

The TransactionID field will be repurposed for step-by-step measurements
to indicate related observations collected as part of the same flow
(e.g., TCP+TLS+HTTP).

Note that, for now, this change will only affect measurexlite and we're
not planning on changing other libraries for measuring.

Part of https://github.com/ooni/probe/issues/2137
This commit is contained in:
Simone Basso 2022-08-25 13:41:26 +02:00 committed by GitHub
parent c9943dff38
commit 6ef3febf69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 51 additions and 30 deletions

View File

@ -139,7 +139,9 @@ func NewArchivalNetworkEvent(index int64, started time.Duration, operation strin
NumBytes: int64(count),
Operation: operation,
Proto: network,
T0: started.Seconds(),
T: finished.Seconds(),
TransactionID: index,
Tags: []string{},
}
}

View File

@ -442,7 +442,9 @@ func TestNewAnnotationArchivalNetworkEvent(t *testing.T) {
NumBytes: 0,
Operation: operation,
Proto: "",
T0: duration.Seconds(),
T: duration.Seconds(),
TransactionID: index,
Tags: []string{},
}
got := NewAnnotationArchivalNetworkEvent(

View File

@ -82,7 +82,9 @@ func NewArchivalTCPConnectResult(index int64, started time.Duration, address str
Failure: tracex.NewFailure(err),
Success: err == nil,
},
T0: started.Seconds(),
T: finished.Seconds(),
TransactionID: index,
}
}

View File

@ -127,6 +127,7 @@ func NewArchivalDNSLookupResultFromRoundTrip(index int64, started time.Duration,
ResolverAddress: reso.Address(),
T0: started.Seconds(),
T: finished.Seconds(),
TransactionID: index,
}
}

View File

@ -184,6 +184,7 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
NumBytes: 0,
Operation: "quic_handshake_done",
Proto: "",
T0: time.Second.Seconds(),
T: time.Second.Seconds(),
Tags: []string{},
}

View File

@ -86,9 +86,11 @@ func NewArchivalTLSOrQUICHandshakeResult(
NoTLSVerify: config.InsecureSkipVerify,
PeerCertificates: TLSPeerCerts(state, err),
ServerName: config.ServerName,
T0: started.Seconds(),
T: finished.Seconds(),
Tags: []string{},
TLSVersion: netxlite.TLSVersionString(state.Version),
TransactionID: index,
}
}

View File

@ -167,6 +167,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
NumBytes: 0,
Operation: "tls_handshake_done",
Proto: "",
T0: time.Second.Seconds(),
T: time.Second.Seconds(),
Tags: []string{},
}
@ -329,6 +330,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
NumBytes: 0,
Operation: "tls_handshake_done",
Proto: "",
T0: time.Second.Seconds(),
T: time.Second.Seconds(),
Tags: []string{},
}

View File

@ -125,6 +125,7 @@ type ArchivalDNSLookupResult struct {
ResolverAddress string `json:"resolver_address"`
T0 float64 `json:"t0"`
T float64 `json:"t"`
TransactionID int64 `json:"transaction_id"`
}
// ArchivalDNSAnswer is a DNS answer.
@ -149,7 +150,9 @@ type ArchivalTCPConnectResult struct {
IP string `json:"ip"`
Port int `json:"port"`
Status ArchivalTCPConnectStatus `json:"status"`
T0 float64 `json:"t0"`
T float64 `json:"t"`
TransactionID int64 `json:"transaction_id"`
}
// ArchivalTCPConnectStatus is the status of ArchivalTCPConnectResult.
@ -175,9 +178,11 @@ type ArchivalTLSOrQUICHandshakeResult struct {
NoTLSVerify bool `json:"no_tls_verify"`
PeerCertificates []ArchivalMaybeBinaryData `json:"peer_certificates"`
ServerName string `json:"server_name"`
T0 float64 `json:"t0"`
T float64 `json:"t"`
Tags []string `json:"tags"`
TLSVersion string `json:"tls_version"`
TransactionID int64 `json:"transaction_id"`
}
//
@ -191,7 +196,9 @@ type ArchivalHTTPRequestResult struct {
Failure *string `json:"failure"`
Request ArchivalHTTPRequest `json:"request"`
Response ArchivalHTTPResponse `json:"response"`
T0 float64 `json:"t0"`
T float64 `json:"t"`
TransactionID int64 `json:"transaction_id"`
}
// ArchivalHTTPRequest contains an HTTP request.
@ -312,6 +319,8 @@ type ArchivalNetworkEvent struct {
NumBytes int64 `json:"num_bytes,omitempty"`
Operation string `json:"operation"`
Proto string `json:"proto,omitempty"`
T0 float64 `json:"t0"`
T float64 `json:"t"`
TransactionID int64 `json:"transaction_id"`
Tags []string `json:"tags,omitempty"`
}