[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Bin metrics to nearest mult of 8
commit 175b8efb045f2ab89d3524c4e276b2ff7298c61c
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
Date: Tue Jun 11 14:27:42 2019 -0400
Bin metrics to nearest mult of 8
---
broker/metrics.go | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/broker/metrics.go b/broker/metrics.go
index 4159f70..2c798ee 100644
--- a/broker/metrics.go
+++ b/broker/metrics.go
@@ -4,6 +4,7 @@ import (
// "golang.org/x/net/internal/timeseries"
"fmt"
"log"
+ "math"
"net"
"sync"
"time"
@@ -112,9 +113,9 @@ func (m *Metrics) logMetrics() {
for range heartbeat {
m.logger.Println("snowflake-stats-end ")
m.logger.Println("snowflake-ips ", m.countryStats.Display())
- m.logger.Println("snowflake-idle-count ", m.proxyIdleCount)
- m.logger.Println("client-denied-count ", m.clientDeniedCount)
- m.logger.Println("client-snowflake-match-count ", m.clientProxyMatchCount)
+ m.logger.Println("snowflake-idle-count ", binCount(m.proxyIdleCount))
+ m.logger.Println("client-denied-count ", binCount(m.clientDeniedCount))
+ m.logger.Println("client-snowflake-match-count ", binCount(m.clientProxyMatchCount))
//restore all metrics to original values
m.proxyIdleCount = 0
@@ -123,3 +124,8 @@ func (m *Metrics) logMetrics() {
m.countryStats.counts = make(map[string]int)
}
}
+
+// Rounds up a count to the nearest multiple of 8.
+func binCount(count int) int {
+ return int((math.Ceil(float64(count) / 8)) * 8)
+}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits