feat(proxy): add failed connection count stats

For the summary log and for Prometheus metrics.

Log output example:

> In the last 1h0m0s, there were 7 completed successful connections. 2 connections failed. Traffic Relayed ↓ 321 KB (0.10 KB/s), ↑ 123 KB (0.05 KB/s).
This commit is contained in:
WofWca 2025-02-21 02:00:47 +04:00 committed by Shelikhoo
parent 5ef4761968
commit 583178f4f2
No known key found for this signature in database
GPG key ID: 4C9764E9FE80A3DC
5 changed files with 53 additions and 13 deletions

View file

@ -8,6 +8,7 @@ type EventCollector interface {
TrackInBoundTraffic(value int64)
TrackOutBoundTraffic(value int64)
TrackNewConnection(country string)
TrackFailedConnection()
}
type EventMetrics struct {
@ -27,5 +28,7 @@ func (em *EventMetrics) OnNewSnowflakeEvent(e event.SnowflakeEvent) {
case event.EventOnProxyConnectionOver:
e := e.(event.EventOnProxyConnectionOver)
em.collector.TrackNewConnection(e.Country)
case event.EventOnProxyConnectionFailed:
em.collector.TrackFailedConnection()
}
}