aboutsummaryrefslogtreecommitdiff
path: root/proxy
diff options
context:
space:
mode:
authorCecylia Bocovich <cohosh@torproject.org>2023-10-30 12:37:56 -0400
committerCecylia Bocovich <cohosh@torproject.org>2023-10-30 12:42:45 -0400
commit5c5eb2c339f15283094576cba0f8b1083b451c82 (patch)
treef1078631b816e04cb97cab1d886f3676fd51baf7 /proxy
parent018bbd6d657a891429c8777583ae6bec3981d99a (diff)
downloadsnowflake-5c5eb2c339f15283094576cba0f8b1083b451c82.tar.gz
snowflake-5c5eb2c339f15283094576cba0f8b1083b451c82.zip
Modify EventOnProxyStats to include summary data
Diffstat (limited to 'proxy')
-rw-r--r--proxy/lib/pt_event_logger.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/proxy/lib/pt_event_logger.go b/proxy/lib/pt_event_logger.go
index 83ee62e..3d9a770 100644
--- a/proxy/lib/pt_event_logger.go
+++ b/proxy/lib/pt_event_logger.go
@@ -1,7 +1,6 @@
package snowflake_proxy
import (
- "fmt"
"io"
"log"
"time"
@@ -47,11 +46,13 @@ func (p *periodicProxyStats) OnNewSnowflakeEvent(e event.SnowflakeEvent) {
func (p *periodicProxyStats) logTick() error {
inboundSum, outboundSum := p.bytesLogger.GetStat()
- inbound, inboundUnit := formatTraffic(inboundSum)
- outbound, outboundUnit := formatTraffic(outboundSum)
- statString := fmt.Sprintf("In the last %v, there were %v completed connections. Traffic Relayed ↓ %v %v, ↑ %v %v.",
- p.logPeriod.String(), p.connectionCount, inbound, inboundUnit, outbound, outboundUnit)
- p.dispatcher.OnNewSnowflakeEvent(&event.EventOnProxyStats{StatString: statString})
+ e := &event.EventOnProxyStats{
+ SummaryInterval: p.logPeriod,
+ ConnectionCount: p.connectionCount,
+ }
+ e.InboundBytes, e.InboundUnit = formatTraffic(inboundSum)
+ e.OutboundBytes, e.OutboundUnit = formatTraffic(outboundSum)
+ p.dispatcher.OnNewSnowflakeEvent(e)
p.connectionCount = 0
return nil
}