aboutsummaryrefslogtreecommitdiff
path: root/broker
diff options
context:
space:
mode:
authorShelikhoo <xiaokangwang@outlook.com>2022-05-02 14:03:32 +0100
committerShelikhoo <xiaokangwang@outlook.com>2022-06-16 14:06:57 +0100
commitb391d986799459a843e1596c0ffe60c46e2e4d25 (patch)
tree8667523e9e2d37903382da96750ffb9256d09ac1 /broker
parent1b48ee14f47f6b5ac4b061c2bd50aaf58b2fff4f (diff)
downloadsnowflake-b391d986799459a843e1596c0ffe60c46e2e4d25.tar.gz
snowflake-b391d986799459a843e1596c0ffe60c46e2e4d25.zip
Add Proxy Relay URL Support Counting Metrics Output
Diffstat (limited to 'broker')
-rw-r--r--broker/metrics.go28
-rw-r--r--broker/snowflake-broker_test.go4
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() {