From 2a9feb82b55481308c0f6aa9d813e9021b0333ef Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Thu, 5 May 2022 01:59:46 -0400 Subject: Upgraded RPM Calculation Support (Take 1) This patch begins the work on updated RPM calculations using the httptrace infrastructure. Because we are still not able to break out the TLS handshake time due to upstream bugs, there are some workarounds in place. However, the numbers appear much more sane. --- stats/stats.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 stats/stats.go (limited to 'stats/stats.go') diff --git a/stats/stats.go b/stats/stats.go new file mode 100644 index 0000000..a636326 --- /dev/null +++ b/stats/stats.go @@ -0,0 +1,50 @@ +package stats + +import ( + "crypto/tls" + "fmt" + "net/http/httptrace" + "time" + + "github.com/network-quality/goresponsiveness/utilities" +) + +type TraceStats struct { + DnsStart httptrace.DNSStartInfo + DnsDone httptrace.DNSDoneInfo + ConnInfo httptrace.GotConnInfo + HttpInfo httptrace.WroteRequestInfo + TLSConnInfo tls.ConnectionState + ConnectDoneError error + DnsStartTime time.Time + DnsDoneTime time.Time + TLSStartTime utilities.Optional[time.Time] + TLSDoneTime utilities.Optional[time.Time] + ConnectStartTime time.Time + ConnectDoneTime time.Time + GetConnectionStartTime time.Time + GetConnectionDoneTime time.Time + HttpWroteRequestTime time.Time + HttpResponseReadyTime time.Time +} + +func NewStats() *TraceStats { + return &TraceStats{} +} + +func (s *TraceStats) String() string { + return fmt.Sprintf("DnsStart: %v\n", s.DnsStart) + + fmt.Sprintf("DnsDone: %v\n", s.DnsDone) + + fmt.Sprintf("ConnInfo: %v\n", s.ConnInfo) + + fmt.Sprintf("HttpInfo: %v\n", s.HttpInfo) + + fmt.Sprintf("TLSConnInfo: %v\n", s.TLSConnInfo) + + fmt.Sprintf("ConnectDoneError: %v\n", s.ConnectDoneError) + + fmt.Sprintf("DnsStartTime: %v\n", s.DnsStartTime) + + fmt.Sprintf("DnsDoneTime: %v\n", s.DnsDoneTime) + + fmt.Sprintf("TLSDoneTime: %v\n", s.TLSDoneTime) + + fmt.Sprintf("ConnectStartTime: %v\n", s.ConnectStartTime) + + fmt.Sprintf("ConnectDoneTime: %v\n", s.ConnectDoneTime) + + fmt.Sprintf("GetConnectionStartTime: %v\n", s.GetConnectionStartTime) + + fmt.Sprintf("GetConnectionDoneTime: %v\n", s.GetConnectionDoneTime) + + fmt.Sprintf("HttpResponseReadyTime: %v\n", s.HttpResponseReadyTime) +} -- cgit v1.2.3