refactor(tracex): do not depend on strings for event names (#777)

Rather than matching a string, match a type.

This is more robust considering future refactorings.

We're confident the names did not change in _this_ refactoring
because we're still testing the same strings in the tests.

Part of https://github.com/ooni/probe/issues/2121
This commit is contained in:
Simone Basso 2022-06-01 14:32:16 +02:00 committed by GitHub
commit c740be987b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 533 additions and 340 deletions

View file

@ -171,8 +171,8 @@ func (r runner) measure(
// of the latest connect time. We should have one sample in most
// cases, because the connection should be persistent.
for _, ev := range r.saver.Read() {
if ev.Name == netxlite.ConnectOperation {
connectTime = ev.Duration.Seconds()
if _, ok := ev.(*tracex.EventConnectOperation); ok {
connectTime = ev.Value().Duration.Seconds()
}
}
current.ConnectTime = connectTime