Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Anti-censorship
Pluggable Transports
Snowflake
Commits
dd61e2be
Verified
Commit
dd61e2be
authored
May 02, 2022
by
shelikhoo
Browse files
Add Proxy Relay URL Metrics Collection
parent
b78eb74e
Changes
3
Hide whitespace changes
Inline
Side-by-side
broker/ipc.go
View file @
dd61e2be
...
...
@@ -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
...
...
broker/metrics.go
View file @
dd61e2be
...
...
@@ -316,6 +316,7 @@ func initPrometheus() *PromMetrics {
promMetrics
.
ProxyTotal
,
promMetrics
.
AvailableProxies
,
promMetrics
.
ProxyPollWithRelayURLExtensionTotal
,
promMetrics
.
ProxyPollWithoutRelayURLExtensionTotal
,
promMetrics
.
ProxyPollRejectedForRelayURLExtensionTotal
,
)
return
promMetrics
...
...
broker/snowflake-broker_test.go
View file @
dd61e2be
...
...
@@ -560,7 +560,7 @@ func TestMetrics(t *testing.T) {
So
(
metricsStr
,
ShouldContainSubstring
,
"
\n
snowflake-ips-standalone 1
\n
"
)
So
(
metricsStr
,
ShouldContainSubstring
,
"
\n
snowflake-ips-badge 1
\n
"
)
So
(
metricsStr
,
ShouldContainSubstring
,
"
\n
snowflake-ips-webext 1
\n
"
)
So
(
metricsStr
,
ShouldEndWith
,
"
\n
snowflake-ips-total 4
\n
snowflake-idle-count 8
\n
snowflake-proxy-poll-with-relay-url-count 0
\n
snowflake-proxy-poll-without-relay-url-count 8
\n
client-denied-count 0
\n
client-restricted-denied-count 0
\n
client-unrestricted-denied-count 0
\n
client-snowflake-match-count 0
\n
snowflake-ips-nat-restricted 0
\n
snowflake-ips-nat-unrestricted 0
\n
snowflake-ips-nat-unknown 1
\n
"
)
So
(
metricsStr
,
ShouldEndWith
,
"
\n
snowflake-ips-total 4
\n
snowflake-idle-count 8
\n
snowflake-proxy-poll-with-relay-url-count 0
\n
snowflake-proxy-poll-without-relay-url-count 8
\
n
snowflake-proxy-rejected-for-relay-url-count 0
\
n
client-denied-count 0
\n
client-restricted-denied-count 0
\n
client-unrestricted-denied-count 0
\n
client-snowflake-match-count 0
\n
snowflake-ips-nat-restricted 0
\n
snowflake-ips-nat-unrestricted 0
\n
snowflake-ips-nat-unknown 1
\n
"
)
})
//Test addition of client failures
...
...
@@ -584,7 +584,7 @@ func TestMetrics(t *testing.T) {
So
(
buf
.
String
(),
ShouldContainSubstring
,
"
\n
snowflake-ips-standalone 0
\n
"
)
So
(
buf
.
String
(),
ShouldContainSubstring
,
"
\n
snowflake-ips-badge 0
\n
"
)
So
(
buf
.
String
(),
ShouldContainSubstring
,
"
\n
snowflake-ips-webext 0
\n
"
)
So
(
buf
.
String
(),
ShouldContainSubstring
,
"
\n
snowflake-ips-total 0
\n
snowflake-idle-count 0
\n
snowflake-proxy-poll-with-relay-url-count 0
\n
snowflake-proxy-poll-without-relay-url-count 0
\n
client-denied-count 0
\n
client-restricted-denied-count 0
\n
client-unrestricted-denied-count 0
\n
client-snowflake-match-count 0
\n
snowflake-ips-nat-restricted 0
\n
snowflake-ips-nat-unrestricted 0
\n
snowflake-ips-nat-unknown 0
\n
"
)
So
(
buf
.
String
(),
ShouldContainSubstring
,
"
\n
snowflake-ips-total 0
\n
snowflake-idle-count 0
\n
snowflake-proxy-poll-with-relay-url-count 0
\n
snowflake-proxy-poll-without-relay-url-count
0
\n
snowflake-proxy-rejected-for-relay-url-count
0
\n
client-denied-count 0
\n
client-restricted-denied-count 0
\n
client-unrestricted-denied-count 0
\n
client-snowflake-match-count 0
\n
snowflake-ips-nat-restricted 0
\n
snowflake-ips-nat-unrestricted 0
\n
snowflake-ips-nat-unknown 0
\n
"
)
})
//Test addition of client matches
Convey
(
"for client-proxy match"
,
func
()
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment