fix(measurex): use same keys of the OONI data format (#572)

This change should simplify the pipeline's job.

Reference issue: https://github.com/ooni/probe/issues/1817.

I previously dismissed this possibility, but now it seems clear it
is simpler to have a very tabular data format internally and to
convert such a format to OONI's data format when serializing.

The OONI data format is what the pipeline expects, but processing
is easier with a more linear/tabular format.
This commit is contained in:
Simone Basso 2021-11-05 10:46:45 +01:00 committed by GitHub
commit aa27bbe33f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1539 additions and 993 deletions

View file

@ -54,17 +54,14 @@ type dialerDB struct {
// NetworkEvent contains a network event. This kind of events
// are generated by Dialer, QUICDialer, Conn, QUICConn.
type NetworkEvent struct {
// JSON names compatible with df-008-netevents
RemoteAddr string `json:"address"`
Failure *string `json:"failure"`
Count int `json:"num_bytes,omitempty"`
Operation string `json:"operation"`
Network string `json:"proto"`
Finished float64 `json:"t"`
Started float64 `json:"started"`
// Names that are not part of the spec.
Oddity Oddity `json:"oddity"`
RemoteAddr string
Failure *string
Count int
Operation string
Network string
Oddity Oddity
Finished float64
Started float64
}
func (d *dialerDB) DialContext(
@ -78,7 +75,7 @@ func (d *dialerDB) DialContext(
RemoteAddr: address,
Started: started,
Finished: finished,
Failure: NewArchivalFailure(err),
Failure: NewFailure(err),
Oddity: d.computeOddity(err),
Count: 0,
})
@ -128,7 +125,7 @@ func (c *connDB) Read(b []byte) (int, error) {
RemoteAddr: c.remoteAddr,
Started: started,
Finished: finished,
Failure: NewArchivalFailure(err),
Failure: NewFailure(err),
Count: count,
})
return count, err
@ -144,7 +141,7 @@ func (c *connDB) Write(b []byte) (int, error) {
RemoteAddr: c.remoteAddr,
Started: started,
Finished: finished,
Failure: NewArchivalFailure(err),
Failure: NewFailure(err),
Count: count,
})
return count, err
@ -160,7 +157,7 @@ func (c *connDB) Close() error {
RemoteAddr: c.remoteAddr,
Started: started,
Finished: finished,
Failure: NewArchivalFailure(err),
Failure: NewFailure(err),
Count: 0,
})
return err