Increment prometheus proxy_total count once per IP

This fixes a regression from !574 that did not check whether the IP was
unique before incrementing the counter.

Closes https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40470
This commit is contained in:
Cecylia Bocovich 2025-07-08 11:35:56 -04:00
parent d7ebb2f99c
commit 58b1d48e54
No known key found for this signature in database
GPG key ID: 009DE379FD9B7B90

View file

@ -104,6 +104,11 @@ func (m *Metrics) UpdateProxyStats(addr string, proxyType string, natType string
if _, loaded := m.ips.LoadOrStore(addr, true); !loaded {
m.IncrementCounter("proxy-total")
incrementMapCounter(m.proxies, country)
m.promMetrics.ProxyTotal.With(prometheus.Labels{
"nat": natType,
"type": proxyType,
"cc": country,
}).Inc()
}
// update unique IP proxy NAT metrics
@ -132,12 +137,6 @@ func (m *Metrics) UpdateProxyStats(addr string, proxyType string, natType string
m.IncrementCounter("proxy-webext")
}
}
m.promMetrics.ProxyTotal.With(prometheus.Labels{
"nat": natType,
"type": proxyType,
"cc": country,
}).Inc()
}
func (m *Metrics) UpdateClientStats(addr string, rendezvousMethod messages.RendezvousMethod, natType, status string) {