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
b391d986
Verified
Commit
b391d986
authored
May 02, 2022
by
shelikhoo
Browse files
Add Proxy Relay URL Support Counting Metrics Output
parent
1b48ee14
Changes
2
Hide whitespace changes
Inline
Side-by-side
broker/metrics.go
View file @
b391d986
...
...
@@ -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
...
...
broker/snowflake-broker_test.go
View file @
b391d986
...
...
@@ -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
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
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
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
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