Commit 175b8efb authored by Cecylia Bocovich's avatar Cecylia Bocovich
Browse files

Bin metrics to nearest mult of 8

parent 0293674e
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
// "golang.org/x/net/internal/timeseries" // "golang.org/x/net/internal/timeseries"
"fmt" "fmt"
"log" "log"
"math"
"net" "net"
"sync" "sync"
"time" "time"
...@@ -112,9 +113,9 @@ func (m *Metrics) logMetrics() { ...@@ -112,9 +113,9 @@ func (m *Metrics) logMetrics() {
for range heartbeat { for range heartbeat {
m.logger.Println("snowflake-stats-end ") m.logger.Println("snowflake-stats-end ")
m.logger.Println("snowflake-ips ", m.countryStats.Display()) m.logger.Println("snowflake-ips ", m.countryStats.Display())
m.logger.Println("snowflake-idle-count ", m.proxyIdleCount) m.logger.Println("snowflake-idle-count ", binCount(m.proxyIdleCount))
m.logger.Println("client-denied-count ", m.clientDeniedCount) m.logger.Println("client-denied-count ", binCount(m.clientDeniedCount))
m.logger.Println("client-snowflake-match-count ", m.clientProxyMatchCount) m.logger.Println("client-snowflake-match-count ", binCount(m.clientProxyMatchCount))
//restore all metrics to original values //restore all metrics to original values
m.proxyIdleCount = 0 m.proxyIdleCount = 0
...@@ -123,3 +124,8 @@ func (m *Metrics) logMetrics() { ...@@ -123,3 +124,8 @@ func (m *Metrics) logMetrics() {
m.countryStats.counts = make(map[string]int) 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)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment