From 4a3b5c9ab262a6c029c04a6d1e7f6fe038ee9e63 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Wed, 19 Jul 2023 10:45:53 -0400 Subject: [Feature] Add extended-stats for uploads Now that tests are run in sequence, it seems like a good idea to support extended statistics in both directions. Fixes #58 h/t @moeller0 Signed-off-by: Will Hawkins --- networkQuality.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'networkQuality.go') diff --git a/networkQuality.go b/networkQuality.go index ed9dcfa..1e6590b 100644 --- a/networkQuality.go +++ b/networkQuality.go @@ -432,8 +432,7 @@ func main() { downloadDirection.Lgcc = lgc.NewLoadGeneratingConnectionCollection() uploadDirection.Lgcc = lgc.NewLoadGeneratingConnectionCollection() - // We do not do tracing on upload connections so there are no extended stats for those connections! - uploadDirection.ExtendedStatsEligible = false + uploadDirection.ExtendedStatsEligible = true downloadDirection.ExtendedStatsEligible = true generateSelfProbeConfiguration := func() probe.ProbeConfiguration { @@ -956,24 +955,32 @@ func main() { direction.Lgcc.Lock.Lock() defer direction.Lgcc.Lock.Unlock() - // Note: We do not trace upload connections! - downloadLgcCount, err := direction.Lgcc.Len() + lgcCount, err := direction.Lgcc.Len() if err != nil { fmt.Fprintf( os.Stderr, - "Warning: Could not calculate the number of download load-generating connections; aborting extended stats preparation.\n", + "Warning: Could not calculate the number of %v load-generating connections; aborting extended stats preparation.\n", direction.DirectionLabel, ) return } - for i := 0; i < downloadLgcCount; i++ { + + for i := 0; i < lgcCount; i++ { // Assume that extended statistics are available -- the check was done explicitly at // program startup if the calculateExtendedStats flag was set by the user on the command line. currentLgc, _ := direction.Lgcc.Get(i) + + if currentLgc == nil || (*currentLgc).Stats() == nil { + fmt.Fprintf( + os.Stderr, + "Warning: Could not add extended stats for the connection: The LGC was nil or there were no stats available.\n", + ) + continue + } if err := extendedStats.IncorporateConnectionStats( (*currentLgc).Stats().ConnInfo.Conn); err != nil { fmt.Fprintf( os.Stderr, - "Warning: Could not add extended stats for the connection: %v\n", + "Warning: Could not add extended stats for the connection: %v.\n", err, ) } -- cgit v1.2.3