From ecd96721ba5e4f68df71576c94c9d79cac2a4f7c Mon Sep 17 00:00:00 2001 From: Michael Pu Date: Wed, 31 Jan 2024 12:30:51 -0500 Subject: Prune metrics that are reported for rendezvous Signed-off-by: Cecylia Bocovich --- broker/metrics.go | 19 ++++-- broker/snowflake-broker_test.go | 135 ++++++++-------------------------------- broker/sqs_test.go | 15 +---- doc/broker-spec.txt | 83 +++--------------------- 4 files changed, 50 insertions(+), 202 deletions(-) diff --git a/broker/metrics.go b/broker/metrics.go index 5dfcd6c..b24eec9 100644 --- a/broker/metrics.go +++ b/broker/metrics.go @@ -189,7 +189,11 @@ func (m *Metrics) logMetrics() { func (m *Metrics) printMetrics() { m.lock.Lock() - m.logger.Println("snowflake-stats-end", time.Now().UTC().Format("2006-01-02 15:04:05"), fmt.Sprintf("(%d s)", int(metricsResolution.Seconds()))) + m.logger.Println( + "snowflake-stats-end", + time.Now().UTC().Format("2006-01-02 15:04:05"), + fmt.Sprintf("(%d s)", int(metricsResolution.Seconds())), + ) m.logger.Println("snowflake-ips", m.countryStats.Display()) total := len(m.countryStats.unknown) for pType, addresses := range m.countryStats.proxies { @@ -207,11 +211,14 @@ func (m *Metrics) printMetrics() { m.logger.Println("client-unrestricted-denied-count", binCount(sumMapValues(&m.clientUnrestrictedDeniedCount))) m.logger.Println("client-snowflake-match-count", binCount(sumMapValues(&m.clientProxyMatchCount))) - for _, rendezvousMethod := range [3]messages.RendezvousMethod{messages.RendezvousHttp, messages.RendezvousAmpCache, messages.RendezvousSqs} { - m.logger.Printf("client-%s-denied-count %d\n", rendezvousMethod, binCount(m.clientDeniedCount[rendezvousMethod])) - m.logger.Printf("client-%s-restricted-denied-count %d\n", rendezvousMethod, binCount(m.clientRestrictedDeniedCount[rendezvousMethod])) - m.logger.Printf("client-%s-unrestricted-denied-count %d\n", rendezvousMethod, binCount(m.clientUnrestrictedDeniedCount[rendezvousMethod])) - m.logger.Printf("client-snowflake-%s-match-count %d\n", rendezvousMethod, binCount(m.clientProxyMatchCount[rendezvousMethod])) + for _, rendezvousMethod := range [3]messages.RendezvousMethod{ + messages.RendezvousHttp, + messages.RendezvousAmpCache, + messages.RendezvousSqs, + } { + m.logger.Printf("client-%s-count %d\n", rendezvousMethod, binCount( + m.clientDeniedCount[rendezvousMethod]+m.clientProxyMatchCount[rendezvousMethod], + )) } m.logger.Println("snowflake-ips-nat-restricted", len(m.countryStats.natRestricted)) diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go index d894145..8179bb0 100644 --- a/broker/snowflake-broker_test.go +++ b/broker/snowflake-broker_test.go @@ -157,18 +157,9 @@ func TestBroker(t *testing.T) { client-restricted-denied-count 8 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 8 -client-http-restricted-denied-count 8 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 8 +client-ampcache-count 0 +client-sqs-count 0 `) }) @@ -193,18 +184,9 @@ client-snowflake-sqs-match-count 0 client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 8 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 8 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 8 +client-ampcache-count 0 +client-sqs-count 0 `) }) @@ -278,18 +260,9 @@ client-snowflake-sqs-match-count 0 client-restricted-denied-count 8 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 8 -client-http-restricted-denied-count 8 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 8 +client-ampcache-count 0 +client-sqs-count 0 `) }) @@ -314,18 +287,9 @@ client-snowflake-sqs-match-count 0 client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 8 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 8 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 8 +client-ampcache-count 0 +client-sqs-count 0 `) }) @@ -376,18 +340,9 @@ client-snowflake-sqs-match-count 0 client-restricted-denied-count 8 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 8 -client-ampcache-restricted-denied-count 8 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 0 +client-ampcache-count 8 +client-sqs-count 0 `) }) @@ -414,18 +369,9 @@ client-snowflake-sqs-match-count 0 client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 8 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 8 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 0 +client-ampcache-count 8 +client-sqs-count 0 `) }) @@ -782,18 +728,9 @@ client-denied-count 0 client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 0 +client-ampcache-count 0 +client-sqs-count 0 snowflake-ips-nat-restricted 0 snowflake-ips-nat-unrestricted 0 snowflake-ips-nat-unknown 1 @@ -815,18 +752,9 @@ snowflake-ips-nat-unknown 1 client-restricted-denied-count 8 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 8 -client-http-restricted-denied-count 8 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 8 +client-ampcache-count 0 +client-sqs-count 0 `) // Test reset @@ -846,18 +774,9 @@ client-denied-count 0 client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 0 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 0 +client-http-count 0 +client-ampcache-count 0 +client-sqs-count 0 snowflake-ips-nat-restricted 0 snowflake-ips-nat-unrestricted 0 snowflake-ips-nat-unknown 0 diff --git a/broker/sqs_test.go b/broker/sqs_test.go index 0ffb778..216e146 100644 --- a/broker/sqs_test.go +++ b/broker/sqs_test.go @@ -194,18 +194,9 @@ func TestSQS(t *testing.T) { client-restricted-denied-count 0 client-unrestricted-denied-count 0 client-snowflake-match-count 8 -client-http-denied-count 0 -client-http-restricted-denied-count 0 -client-http-unrestricted-denied-count 0 -client-snowflake-http-match-count 0 -client-ampcache-denied-count 0 -client-ampcache-restricted-denied-count 0 -client-ampcache-unrestricted-denied-count 0 -client-snowflake-ampcache-match-count 0 -client-sqs-denied-count 0 -client-sqs-restricted-denied-count 0 -client-sqs-unrestricted-denied-count 0 -client-snowflake-sqs-match-count 8 +client-http-count 0 +client-ampcache-count 0 +client-sqs-count 8 `) wg.Done() } diff --git a/doc/broker-spec.txt b/doc/broker-spec.txt index e6b51b1..6738cf6 100644 --- a/doc/broker-spec.txt +++ b/doc/broker-spec.txt @@ -82,96 +82,27 @@ Metrics data from the Snowflake broker can be retrieved by sending an HTTP GET r A count of the number of times a client successfully received a proxy from the broker, rounded up to the nearest multiple of 8. - "client-http-denied-count" NUM NL + "client-http-count" NUM NL [At most once.] A count of the number of times a client has requested a proxy using - the HTTP rendezvous method from the broker but no proxies were - available, rounded up to the nearest multiple of 8. - - "client-http-restricted-denied-count" NUM NL - [At most once.] - - A count of the number of times a client with a restricted or - unknown NAT type has requested a proxy using the HTTP rendezvous - method from the broker but no proxies were available, rounded up to - the nearest multiple of 8. - - "client-http-unrestricted-denied-count" NUM NL - [At most once.] - - A count of the number of times a client with an unrestricted NAT - type has requested a proxy using the HTTP rendezvous method from - the broker but no proxies were available, rounded up to the nearest + the HTTP rendezvous method from the broker, rounded up to the nearest multiple of 8. - "client-snowflake-http-match-count" NUM NL - [At most once.] - - A count of the number of times a client successfully received a - proxy using the HTTP rendezvous method from the broker, rounded - up to the nearest multiple of 8. - - "client-ampcache-denied-count" NUM NL + "client-ampcache-count" NUM NL [At most once.] A count of the number of times a client has requested a proxy using - the ampcache rendezvous method from the broker but no proxies were - available, rounded up to the nearest multiple of 8. - - "client-ampcache-restricted-denied-count" NUM NL - [At most once.] + the ampcache rendezvous method from the broker, rounded up to the + nearest multiple of 8. - A count of the number of times a client with a restricted or - unknown NAT type has requested a proxy using the ampcache rendezvous - method from the broker but no proxies were available, rounded up to - the nearest multiple of 8. - - "client-ampcache-unrestricted-denied-count" NUM NL - [At most once.] - - A count of the number of times a client with an unrestricted NAT - type has requested a proxy using the ampcache rendezvous method from - the broker but no proxies were available, rounded up to the nearest - multiple of 8. - - "client-snowflake-ampcache-match-count" NUM NL - [At most once.] - - A count of the number of times a client successfully received a - proxy using the ampcache rendezvous method from the broker, rounded - up to the nearest multiple of 8. - - "client-sqs-denied-count" NUM NL + "client-sqs-count" NUM NL [At most once.] A count of the number of times a client has requested a proxy using - the sqs rendezvous method from the broker but no proxies were - available, rounded up to the nearest multiple of 8. - - "client-sqs-restricted-denied-count" NUM NL - [At most once.] - - A count of the number of times a client with a restricted or - unknown NAT type has requested a proxy using the sqs rendezvous - method from the broker but no proxies were available, rounded up to - the nearest multiple of 8. - - "client-sqs-unrestricted-denied-count" NUM NL - [At most once.] - - A count of the number of times a client with an unrestricted NAT - type has requested a proxy using the sqs rendezvous method from - the broker but no proxies were available, rounded up to the nearest + the sqs rendezvous method from the broker, rounded up to the nearest multiple of 8. - "client-snowflake-sqs-match-count" NUM NL - [At most once.] - - A count of the number of times a client successfully received a - proxy using the sqs rendezvous method from the broker, rounded - up to the nearest multiple of 8. - "snowflake-ips-nat-restricted" NUM NL [At most once.] -- cgit v1.2.3-54-g00ecf