[tor-commits] [pluggable-transports/snowflake] 19/31: Add Proxy Relay URL Support Counting Metrics Output

gitolite role git at cupani.torproject.org
Thu Jun 16 17:04:06 UTC 2022


This is an automated email from the git hooks/post-receive script.

shelikhoo pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit b391d986799459a843e1596c0ffe60c46e2e4d25
Author: Shelikhoo <xiaokangwang at outlook.com>
AuthorDate: Mon May 2 14:03:32 2022 +0100

    Add Proxy Relay URL Support Counting Metrics Output
---
 broker/metrics.go               | 28 ++++++++++++++++++++++++++++
 broker/snowflake-broker_test.go |  4 ++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/broker/metrics.go b/broker/metrics.go
index c642045..5d95cb4 100644
--- a/broker/metrics.go
+++ b/broker/metrics.go
@@ -49,6 +49,9 @@ type Metrics struct {
 	clientUnrestrictedDeniedCount uint
 	clientProxyMatchCount         uint
 
+	proxyPollWithRelayURLExtension    uint
+	proxyPollWithoutRelayURLExtension uint
+
 	// synchronization for access to snowflake metrics
 	lock sync.Mutex
 
@@ -189,6 +192,8 @@ func (m *Metrics) printMetrics() {
 	}
 	m.logger.Println("snowflake-ips-total", total)
 	m.logger.Println("snowflake-idle-count", binCount(m.proxyIdleCount))
+	m.logger.Println("snowflake-proxy-poll-with-relay-url-count", binCount(m.proxyPollWithRelayURLExtension))
+	m.logger.Println("snowflake-proxy-poll-without-relay-url-count", binCount(m.proxyPollWithoutRelayURLExtension))
 	m.logger.Println("client-denied-count", binCount(m.clientDeniedCount))
 	m.logger.Println("client-restricted-denied-count", binCount(m.clientRestrictedDeniedCount))
 	m.logger.Println("client-unrestricted-denied-count", binCount(m.clientUnrestrictedDeniedCount))
@@ -227,6 +232,9 @@ type PromMetrics struct {
 	ProxyPollTotal   *RoundedCounterVec
 	ClientPollTotal  *RoundedCounterVec
 	AvailableProxies *prometheus.GaugeVec
+
+	ProxyPollWithRelayURLExtensionTotal    *RoundedCounterVec
+	ProxyPollWithoutRelayURLExtensionTotal *RoundedCounterVec
 }
 
 // Initialize metrics for prometheus exporter
@@ -262,6 +270,24 @@ func initPrometheus() *PromMetrics {
 		[]string{"nat", "status"},
 	)
 
+	promMetrics.ProxyPollWithRelayURLExtensionTotal = NewRoundedCounterVec(
+		prometheus.CounterOpts{
+			Namespace: prometheusNamespace,
+			Name:      "rounded_proxy_poll_with_relay_url_extension_total",
+			Help:      "The number of snowflake proxy polls with Relay URL Extension, rounded up to a multiple of 8",
+		},
+		[]string{"nat", "status"},
+	)
+
+	promMetrics.ProxyPollWithoutRelayURLExtensionTotal = NewRoundedCounterVec(
+		prometheus.CounterOpts{
+			Namespace: prometheusNamespace,
+			Name:      "rounded_proxy_poll_without_relay_url_extension_total",
+			Help:      "The number of snowflake proxy polls without Relay URL Extension, rounded up to a multiple of 8",
+		},
+		[]string{"nat", "status"},
+	)
+
 	promMetrics.ClientPollTotal = NewRoundedCounterVec(
 		prometheus.CounterOpts{
 			Namespace: prometheusNamespace,
@@ -275,6 +301,8 @@ func initPrometheus() *PromMetrics {
 	promMetrics.registry.MustRegister(
 		promMetrics.ClientPollTotal, promMetrics.ProxyPollTotal,
 		promMetrics.ProxyTotal, promMetrics.AvailableProxies,
+		promMetrics.ProxyPollWithRelayURLExtensionTotal,
+		promMetrics.ProxyPollWithoutRelayURLExtensionTotal,
 	)
 
 	return promMetrics
diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go
index fdd1114..6a3ba62 100644
--- a/broker/snowflake-broker_test.go
+++ b/broker/snowflake-broker_test.go
@@ -560,7 +560,7 @@ func TestMetrics(t *testing.T) {
 			So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-standalone 1\n")
 			So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-badge 1\n")
 			So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-webext 1\n")
-			So(metricsStr, ShouldEndWith, "\nsnowflake-ips-total 4\nsnowflake-idle-count 8\nclient-denied-count 0\nclient-restricted-denied-count 0\nclient-unrestricted-denied-count 0\nclient-snowflake-match-count 0\nsnowflake-ips-nat-restricted 0\nsnowflake-ips-nat-unrestricted 0\nsnowflake-ips-nat-unknown 1\n")
+			So(metricsStr, ShouldEndWith, "\nsnowflake-ips-total 4\nsnowflake-idle-count 8\nsnowflake-proxy-poll-with-relay-url-count 0\nsnowflake-proxy-poll-without-relay-url-count 8\nclient-denied-count 0\nclient-restricted-denied-count 0\nclient-unrestricted-denied-count 0\nclient-snowflake-match-count 0\nsnowflake-ips-nat-restricted 0\nsnowflake-ips-nat-unrestricted 0\nsnowflake-ips-nat-unknown 1\n")
 		})
 
 		//Test addition of client failures
@@ -584,7 +584,7 @@ func TestMetrics(t *testing.T) {
 			So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-standalone 0\n")
 			So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-badge 0\n")
 			So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-webext 0\n")
-			So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-total 0\nsnowflake-idle-count 0\nclient-denied-count 0\nclient-restricted-denied-count 0\nclient-unrestricted-denied-count 0\nclient-snowflake-match-count 0\nsnowflake-ips-nat-restricted 0\nsnowflake-ips-nat-unrestricted 0\nsnowflake-ips-nat-unknown 0\n")
+			So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-total 0\nsnowflake-idle-count 0\nsnowflake-proxy-poll-with-relay-url-count 0\nsnowflake-proxy-poll-without-relay-url-count 0\nclient-denied-count 0\nclient-restricted-denied-count 0\nclient-unrestricted-denied-count 0\nclient-snowflake-match-count 0\nsnowflake-ips-nat-restricted 0\nsnowflake-ips-nat-unrestricted 0\nsnowflake-ips-nat-unknown 0\n")
 		})
 		//Test addition of client matches
 		Convey("for client-proxy match", func() {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list