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
fa7d1e2b
Verified
Commit
fa7d1e2b
authored
May 27, 2022
by
shelikhoo
Browse files
Add distinct IP counter to metrics
parent
211254fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
broker/metrics.go
View file @
fa7d1e2b
...
...
@@ -14,6 +14,7 @@ import (
"sync"
"time"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/ipsetsink/sinkcluster"
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"
"github.com/prometheus/client_golang/prometheus"
"gitlab.torproject.org/tpo/anti-censorship/geoip"
...
...
@@ -41,6 +42,8 @@ type Metrics struct {
logger
*
log
.
Logger
geoipdb
*
geoip
.
Geoip
distinctIPWriter
*
sinkcluster
.
ClusterWriter
countryStats
CountryStats
clientRoundtripEstimate
time
.
Duration
proxyIdleCount
uint
...
...
@@ -324,3 +327,13 @@ func initPrometheus() *PromMetrics {
return
promMetrics
}
func
(
m
*
Metrics
)
RecordIPAddress
(
ip
string
)
{
if
m
.
distinctIPWriter
!=
nil
{
m
.
distinctIPWriter
.
AddIPToSet
(
ip
)
}
}
func
(
m
*
Metrics
)
SetIPAddressRecorder
(
recorder
*
sinkcluster
.
ClusterWriter
)
{
m
.
distinctIPWriter
=
recorder
}
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