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:
@@ -134,13 +134,15 @@ func addrStringIfNotNil(addr net.Addr) (out string) {
|
||||
func NewArchivalNetworkEvent(index int64, started time.Duration, operation string, network string,
|
||||
address string, count int, err error, finished time.Duration) *model.ArchivalNetworkEvent {
|
||||
return &model.ArchivalNetworkEvent{
|
||||
Address: address,
|
||||
Failure: tracex.NewFailure(err),
|
||||
NumBytes: int64(count),
|
||||
Operation: operation,
|
||||
Proto: network,
|
||||
T: finished.Seconds(),
|
||||
Tags: []string{},
|
||||
Address: address,
|
||||
Failure: tracex.NewFailure(err),
|
||||
NumBytes: int64(count),
|
||||
Operation: operation,
|
||||
Proto: network,
|
||||
T0: started.Seconds(),
|
||||
T: finished.Seconds(),
|
||||
TransactionID: index,
|
||||
Tags: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -437,13 +437,15 @@ func TestNewAnnotationArchivalNetworkEvent(t *testing.T) {
|
||||
operation = "tls_handshake_start"
|
||||
)
|
||||
expect := &model.ArchivalNetworkEvent{
|
||||
Address: "",
|
||||
Failure: nil,
|
||||
NumBytes: 0,
|
||||
Operation: operation,
|
||||
Proto: "",
|
||||
T: duration.Seconds(),
|
||||
Tags: []string{},
|
||||
Address: "",
|
||||
Failure: nil,
|
||||
NumBytes: 0,
|
||||
Operation: operation,
|
||||
Proto: "",
|
||||
T0: duration.Seconds(),
|
||||
T: duration.Seconds(),
|
||||
TransactionID: index,
|
||||
Tags: []string{},
|
||||
}
|
||||
got := NewAnnotationArchivalNetworkEvent(
|
||||
index, duration, operation,
|
||||
|
||||
@@ -82,7 +82,9 @@ func NewArchivalTCPConnectResult(index int64, started time.Duration, address str
|
||||
Failure: tracex.NewFailure(err),
|
||||
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(),
|
||||
T0: started.Seconds(),
|
||||
T: finished.Seconds(),
|
||||
TransactionID: index,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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{},
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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{},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user