From d4a0d400be96b8dda43096d41bdd6a1fc1fd4245 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Tue, 23 May 2023 00:04:04 -0400 Subject: Additional debugging around non-reused connections When a probe does not properly reuse an existing connection, do some additional logging to help the debugging process. --- probe/probe.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'probe') diff --git a/probe/probe.go b/probe/probe.go index 5777bb3..3a38e3f 100644 --- a/probe/probe.go +++ b/probe/probe.go @@ -20,11 +20,13 @@ import ( "io" "net/http" "net/http/httptrace" + "os" "sync" "time" "github.com/network-quality/goresponsiveness/debug" "github.com/network-quality/goresponsiveness/extendedstats" + "github.com/network-quality/goresponsiveness/lgc" "github.com/network-quality/goresponsiveness/utilities" ) @@ -74,6 +76,7 @@ func Probe( managingCtx context.Context, waitGroup *sync.WaitGroup, client *http.Client, + lgc lgc.LoadGeneratingConnection, probeUrl string, probeHost string, // optional: for use with a test_endpoint probeType ProbeType, @@ -81,7 +84,6 @@ func Probe( captureExtendedStats bool, debugging *debug.DebugWithPrefix, ) error { - if waitGroup != nil { waitGroup.Add(1) defer waitGroup.Done() @@ -143,6 +145,15 @@ func Probe( // We must have reused the connection if we are a self probe! if (probeType == SelfUp || probeType == SelfDown) && !probeTracer.stats.ConnectionReused { + if !utilities.IsInterfaceNil(lgc) { + fmt.Fprintf(os.Stderr, + "(%s) (%s Probe %v) Probe should have reused a connection, but it didn't (connection status: %v)!\n", + debugging.Prefix, + probeType.Value(), + probeId, + lgc.Status(), + ) + } panic(!probeTracer.stats.ConnectionReused) } -- cgit v1.2.3