mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Add Proxy Relay URL Support Counting Metrics Output
This commit is contained in:
parent
1b48ee14f4
commit
b391d98679
2 changed files with 30 additions and 2 deletions
|
@ -49,6 +49,9 @@ type Metrics struct {
|
||||||
clientUnrestrictedDeniedCount uint
|
clientUnrestrictedDeniedCount uint
|
||||||
clientProxyMatchCount uint
|
clientProxyMatchCount uint
|
||||||
|
|
||||||
|
proxyPollWithRelayURLExtension uint
|
||||||
|
proxyPollWithoutRelayURLExtension uint
|
||||||
|
|
||||||
// synchronization for access to snowflake metrics
|
// synchronization for access to snowflake metrics
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
|
|
||||||
|
@ -189,6 +192,8 @@ func (m *Metrics) printMetrics() {
|
||||||
}
|
}
|
||||||
m.logger.Println("snowflake-ips-total", total)
|
m.logger.Println("snowflake-ips-total", total)
|
||||||
m.logger.Println("snowflake-idle-count", binCount(m.proxyIdleCount))
|
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-denied-count", binCount(m.clientDeniedCount))
|
||||||
m.logger.Println("client-restricted-denied-count", binCount(m.clientRestrictedDeniedCount))
|
m.logger.Println("client-restricted-denied-count", binCount(m.clientRestrictedDeniedCount))
|
||||||
m.logger.Println("client-unrestricted-denied-count", binCount(m.clientUnrestrictedDeniedCount))
|
m.logger.Println("client-unrestricted-denied-count", binCount(m.clientUnrestrictedDeniedCount))
|
||||||
|
@ -227,6 +232,9 @@ type PromMetrics struct {
|
||||||
ProxyPollTotal *RoundedCounterVec
|
ProxyPollTotal *RoundedCounterVec
|
||||||
ClientPollTotal *RoundedCounterVec
|
ClientPollTotal *RoundedCounterVec
|
||||||
AvailableProxies *prometheus.GaugeVec
|
AvailableProxies *prometheus.GaugeVec
|
||||||
|
|
||||||
|
ProxyPollWithRelayURLExtensionTotal *RoundedCounterVec
|
||||||
|
ProxyPollWithoutRelayURLExtensionTotal *RoundedCounterVec
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize metrics for prometheus exporter
|
// Initialize metrics for prometheus exporter
|
||||||
|
@ -262,6 +270,24 @@ func initPrometheus() *PromMetrics {
|
||||||
[]string{"nat", "status"},
|
[]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(
|
promMetrics.ClientPollTotal = NewRoundedCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Namespace: prometheusNamespace,
|
Namespace: prometheusNamespace,
|
||||||
|
@ -275,6 +301,8 @@ func initPrometheus() *PromMetrics {
|
||||||
promMetrics.registry.MustRegister(
|
promMetrics.registry.MustRegister(
|
||||||
promMetrics.ClientPollTotal, promMetrics.ProxyPollTotal,
|
promMetrics.ClientPollTotal, promMetrics.ProxyPollTotal,
|
||||||
promMetrics.ProxyTotal, promMetrics.AvailableProxies,
|
promMetrics.ProxyTotal, promMetrics.AvailableProxies,
|
||||||
|
promMetrics.ProxyPollWithRelayURLExtensionTotal,
|
||||||
|
promMetrics.ProxyPollWithoutRelayURLExtensionTotal,
|
||||||
)
|
)
|
||||||
|
|
||||||
return promMetrics
|
return promMetrics
|
||||||
|
|
|
@ -560,7 +560,7 @@ func TestMetrics(t *testing.T) {
|
||||||
So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-standalone 1\n")
|
So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-standalone 1\n")
|
||||||
So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-badge 1\n")
|
So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-badge 1\n")
|
||||||
So(metricsStr, ShouldContainSubstring, "\nsnowflake-ips-webext 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
|
//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-standalone 0\n")
|
||||||
So(buf.String(), ShouldContainSubstring, "\nsnowflake-ips-badge 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-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
|
//Test addition of client matches
|
||||||
Convey("for client-proxy match", func() {
|
Convey("for client-proxy match", func() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue