mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Add distinct IP counter to metrics
This commit is contained in:
parent
211254fa98
commit
fa7d1e2bb7
1 changed files with 13 additions and 0 deletions
|
@ -14,6 +14,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/ipsetsink/sinkcluster"
|
||||||
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"
|
"git.torproject.org/pluggable-transports/snowflake.git/v2/common/messages"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"gitlab.torproject.org/tpo/anti-censorship/geoip"
|
"gitlab.torproject.org/tpo/anti-censorship/geoip"
|
||||||
|
@ -41,6 +42,8 @@ type Metrics struct {
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
geoipdb *geoip.Geoip
|
geoipdb *geoip.Geoip
|
||||||
|
|
||||||
|
distinctIPWriter *sinkcluster.ClusterWriter
|
||||||
|
|
||||||
countryStats CountryStats
|
countryStats CountryStats
|
||||||
clientRoundtripEstimate time.Duration
|
clientRoundtripEstimate time.Duration
|
||||||
proxyIdleCount uint
|
proxyIdleCount uint
|
||||||
|
@ -324,3 +327,13 @@ func initPrometheus() *PromMetrics {
|
||||||
|
|
||||||
return 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
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue