mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Add Proxy Relay URL Metrics Collection
This commit is contained in:
parent
b78eb74e42
commit
dd61e2be0f
3 changed files with 20 additions and 2 deletions
|
@ -71,7 +71,24 @@ func (i *IPC) ProxyPolls(arg messages.Arg, response *[]byte) error {
|
|||
return messages.ErrBadRequest
|
||||
}
|
||||
|
||||
if !relayPatternSupported {
|
||||
i.ctx.metrics.lock.Lock()
|
||||
i.ctx.metrics.proxyPollWithoutRelayURLExtension++
|
||||
i.ctx.metrics.promMetrics.ProxyPollWithoutRelayURLExtensionTotal.With(prometheus.Labels{"nat": natType}).Inc()
|
||||
i.ctx.metrics.lock.Unlock()
|
||||
} else {
|
||||
i.ctx.metrics.lock.Lock()
|
||||
i.ctx.metrics.proxyPollWithRelayURLExtension++
|
||||
i.ctx.metrics.promMetrics.ProxyPollWithRelayURLExtensionTotal.With(prometheus.Labels{"nat": natType}).Inc()
|
||||
i.ctx.metrics.lock.Unlock()
|
||||
}
|
||||
|
||||
if !i.ctx.CheckProxyRelayPattern(relayPattern, !relayPatternSupported) {
|
||||
i.ctx.metrics.lock.Lock()
|
||||
i.ctx.metrics.proxyPollRejectedWithRelayURLExtension++
|
||||
i.ctx.metrics.promMetrics.ProxyPollRejectedForRelayURLExtensionTotal.With(prometheus.Labels{"nat": natType}).Inc()
|
||||
i.ctx.metrics.lock.Unlock()
|
||||
|
||||
log.Printf("bad request: rejected relay pattern from proxy = %v", messages.ErrBadRequest)
|
||||
b, err := messages.EncodePollResponseWithRelayURL("", false, "", "", "incorrect relay pattern")
|
||||
*response = b
|
||||
|
|
|
@ -316,6 +316,7 @@ func initPrometheus() *PromMetrics {
|
|||
promMetrics.ProxyTotal, promMetrics.AvailableProxies,
|
||||
promMetrics.ProxyPollWithRelayURLExtensionTotal,
|
||||
promMetrics.ProxyPollWithoutRelayURLExtensionTotal,
|
||||
promMetrics.ProxyPollRejectedForRelayURLExtensionTotal,
|
||||
)
|
||||
|
||||
return promMetrics
|
||||
|
|
|
@ -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\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")
|
||||
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\nsnowflake-proxy-rejected-for-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 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\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")
|
||||
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\nsnowflake-proxy-rejected-for-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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue