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:
parent
c9943dff38
commit
6ef3febf69
|
@ -134,13 +134,15 @@ func addrStringIfNotNil(addr net.Addr) (out string) {
|
||||||
func NewArchivalNetworkEvent(index int64, started time.Duration, operation string, network string,
|
func NewArchivalNetworkEvent(index int64, started time.Duration, operation string, network string,
|
||||||
address string, count int, err error, finished time.Duration) *model.ArchivalNetworkEvent {
|
address string, count int, err error, finished time.Duration) *model.ArchivalNetworkEvent {
|
||||||
return &model.ArchivalNetworkEvent{
|
return &model.ArchivalNetworkEvent{
|
||||||
Address: address,
|
Address: address,
|
||||||
Failure: tracex.NewFailure(err),
|
Failure: tracex.NewFailure(err),
|
||||||
NumBytes: int64(count),
|
NumBytes: int64(count),
|
||||||
Operation: operation,
|
Operation: operation,
|
||||||
Proto: network,
|
Proto: network,
|
||||||
T: finished.Seconds(),
|
T0: started.Seconds(),
|
||||||
Tags: []string{},
|
T: finished.Seconds(),
|
||||||
|
TransactionID: index,
|
||||||
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -437,13 +437,15 @@ func TestNewAnnotationArchivalNetworkEvent(t *testing.T) {
|
||||||
operation = "tls_handshake_start"
|
operation = "tls_handshake_start"
|
||||||
)
|
)
|
||||||
expect := &model.ArchivalNetworkEvent{
|
expect := &model.ArchivalNetworkEvent{
|
||||||
Address: "",
|
Address: "",
|
||||||
Failure: nil,
|
Failure: nil,
|
||||||
NumBytes: 0,
|
NumBytes: 0,
|
||||||
Operation: operation,
|
Operation: operation,
|
||||||
Proto: "",
|
Proto: "",
|
||||||
T: duration.Seconds(),
|
T0: duration.Seconds(),
|
||||||
Tags: []string{},
|
T: duration.Seconds(),
|
||||||
|
TransactionID: index,
|
||||||
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
got := NewAnnotationArchivalNetworkEvent(
|
got := NewAnnotationArchivalNetworkEvent(
|
||||||
index, duration, operation,
|
index, duration, operation,
|
||||||
|
|
|
@ -82,7 +82,9 @@ func NewArchivalTCPConnectResult(index int64, started time.Duration, address str
|
||||||
Failure: tracex.NewFailure(err),
|
Failure: tracex.NewFailure(err),
|
||||||
Success: err == nil,
|
Success: err == nil,
|
||||||
},
|
},
|
||||||
T: finished.Seconds(),
|
T0: started.Seconds(),
|
||||||
|
T: finished.Seconds(),
|
||||||
|
TransactionID: index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ func NewArchivalDNSLookupResultFromRoundTrip(index int64, started time.Duration,
|
||||||
ResolverAddress: reso.Address(),
|
ResolverAddress: reso.Address(),
|
||||||
T0: started.Seconds(),
|
T0: started.Seconds(),
|
||||||
T: finished.Seconds(),
|
T: finished.Seconds(),
|
||||||
|
TransactionID: index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,6 +184,7 @@ func TestNewQUICDialerWithoutResolver(t *testing.T) {
|
||||||
NumBytes: 0,
|
NumBytes: 0,
|
||||||
Operation: "quic_handshake_done",
|
Operation: "quic_handshake_done",
|
||||||
Proto: "",
|
Proto: "",
|
||||||
|
T0: time.Second.Seconds(),
|
||||||
T: time.Second.Seconds(),
|
T: time.Second.Seconds(),
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,11 @@ func NewArchivalTLSOrQUICHandshakeResult(
|
||||||
NoTLSVerify: config.InsecureSkipVerify,
|
NoTLSVerify: config.InsecureSkipVerify,
|
||||||
PeerCertificates: TLSPeerCerts(state, err),
|
PeerCertificates: TLSPeerCerts(state, err),
|
||||||
ServerName: config.ServerName,
|
ServerName: config.ServerName,
|
||||||
|
T0: started.Seconds(),
|
||||||
T: finished.Seconds(),
|
T: finished.Seconds(),
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
TLSVersion: netxlite.TLSVersionString(state.Version),
|
TLSVersion: netxlite.TLSVersionString(state.Version),
|
||||||
|
TransactionID: index,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
NumBytes: 0,
|
NumBytes: 0,
|
||||||
Operation: "tls_handshake_done",
|
Operation: "tls_handshake_done",
|
||||||
Proto: "",
|
Proto: "",
|
||||||
|
T0: time.Second.Seconds(),
|
||||||
T: time.Second.Seconds(),
|
T: time.Second.Seconds(),
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
|
@ -329,6 +330,7 @@ func TestNewTLSHandshakerStdlib(t *testing.T) {
|
||||||
NumBytes: 0,
|
NumBytes: 0,
|
||||||
Operation: "tls_handshake_done",
|
Operation: "tls_handshake_done",
|
||||||
Proto: "",
|
Proto: "",
|
||||||
|
T0: time.Second.Seconds(),
|
||||||
T: time.Second.Seconds(),
|
T: time.Second.Seconds(),
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ type ArchivalDNSLookupResult struct {
|
||||||
ResolverAddress string `json:"resolver_address"`
|
ResolverAddress string `json:"resolver_address"`
|
||||||
T0 float64 `json:"t0"`
|
T0 float64 `json:"t0"`
|
||||||
T float64 `json:"t"`
|
T float64 `json:"t"`
|
||||||
|
TransactionID int64 `json:"transaction_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArchivalDNSAnswer is a DNS answer.
|
// ArchivalDNSAnswer is a DNS answer.
|
||||||
|
@ -146,10 +147,12 @@ type ArchivalDNSAnswer struct {
|
||||||
//
|
//
|
||||||
// See https://github.com/ooni/spec/blob/master/data-formats/df-005-tcpconnect.md.
|
// See https://github.com/ooni/spec/blob/master/data-formats/df-005-tcpconnect.md.
|
||||||
type ArchivalTCPConnectResult struct {
|
type ArchivalTCPConnectResult struct {
|
||||||
IP string `json:"ip"`
|
IP string `json:"ip"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
Status ArchivalTCPConnectStatus `json:"status"`
|
Status ArchivalTCPConnectStatus `json:"status"`
|
||||||
T float64 `json:"t"`
|
T0 float64 `json:"t0"`
|
||||||
|
T float64 `json:"t"`
|
||||||
|
TransactionID int64 `json:"transaction_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArchivalTCPConnectStatus is the status of ArchivalTCPConnectResult.
|
// ArchivalTCPConnectStatus is the status of ArchivalTCPConnectResult.
|
||||||
|
@ -175,9 +178,11 @@ type ArchivalTLSOrQUICHandshakeResult struct {
|
||||||
NoTLSVerify bool `json:"no_tls_verify"`
|
NoTLSVerify bool `json:"no_tls_verify"`
|
||||||
PeerCertificates []ArchivalMaybeBinaryData `json:"peer_certificates"`
|
PeerCertificates []ArchivalMaybeBinaryData `json:"peer_certificates"`
|
||||||
ServerName string `json:"server_name"`
|
ServerName string `json:"server_name"`
|
||||||
|
T0 float64 `json:"t0"`
|
||||||
T float64 `json:"t"`
|
T float64 `json:"t"`
|
||||||
Tags []string `json:"tags"`
|
Tags []string `json:"tags"`
|
||||||
TLSVersion string `json:"tls_version"`
|
TLSVersion string `json:"tls_version"`
|
||||||
|
TransactionID int64 `json:"transaction_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -188,10 +193,12 @@ type ArchivalTLSOrQUICHandshakeResult struct {
|
||||||
//
|
//
|
||||||
// See https://github.com/ooni/spec/blob/master/data-formats/df-001-httpt.md.
|
// See https://github.com/ooni/spec/blob/master/data-formats/df-001-httpt.md.
|
||||||
type ArchivalHTTPRequestResult struct {
|
type ArchivalHTTPRequestResult struct {
|
||||||
Failure *string `json:"failure"`
|
Failure *string `json:"failure"`
|
||||||
Request ArchivalHTTPRequest `json:"request"`
|
Request ArchivalHTTPRequest `json:"request"`
|
||||||
Response ArchivalHTTPResponse `json:"response"`
|
Response ArchivalHTTPResponse `json:"response"`
|
||||||
T float64 `json:"t"`
|
T0 float64 `json:"t0"`
|
||||||
|
T float64 `json:"t"`
|
||||||
|
TransactionID int64 `json:"transaction_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ArchivalHTTPRequest contains an HTTP request.
|
// ArchivalHTTPRequest contains an HTTP request.
|
||||||
|
@ -307,11 +314,13 @@ type ArchivalHTTPTor struct {
|
||||||
//
|
//
|
||||||
// See https://github.com/ooni/spec/blob/master/data-formats/df-008-netevents.md.
|
// See https://github.com/ooni/spec/blob/master/data-formats/df-008-netevents.md.
|
||||||
type ArchivalNetworkEvent struct {
|
type ArchivalNetworkEvent struct {
|
||||||
Address string `json:"address,omitempty"`
|
Address string `json:"address,omitempty"`
|
||||||
Failure *string `json:"failure"`
|
Failure *string `json:"failure"`
|
||||||
NumBytes int64 `json:"num_bytes,omitempty"`
|
NumBytes int64 `json:"num_bytes,omitempty"`
|
||||||
Operation string `json:"operation"`
|
Operation string `json:"operation"`
|
||||||
Proto string `json:"proto,omitempty"`
|
Proto string `json:"proto,omitempty"`
|
||||||
T float64 `json:"t"`
|
T0 float64 `json:"t0"`
|
||||||
Tags []string `json:"tags,omitempty"`
|
T float64 `json:"t"`
|
||||||
|
TransactionID int64 `json:"transaction_id"`
|
||||||
|
Tags []string `json:"tags,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user