mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
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:
parent
5ef4761968
commit
583178f4f2
5 changed files with 53 additions and 13 deletions
|
@ -75,6 +75,8 @@ func (e EventOnProxyClientConnected) String() string {
|
|||
return fmt.Sprintf("client connected")
|
||||
}
|
||||
|
||||
// The connection with the client has now been closed,
|
||||
// after getting successfully established.
|
||||
type EventOnProxyConnectionOver struct {
|
||||
SnowflakeEvent
|
||||
Country string
|
||||
|
@ -84,17 +86,30 @@ func (e EventOnProxyConnectionOver) String() string {
|
|||
return fmt.Sprintf("Proxy connection closed")
|
||||
}
|
||||
|
||||
// Rendezvous with a client succeeded,
|
||||
// but a data channel has not been created.
|
||||
type EventOnProxyConnectionFailed struct {
|
||||
SnowflakeEvent
|
||||
}
|
||||
|
||||
func (e EventOnProxyConnectionFailed) String() string {
|
||||
return "Failed to connect to the client"
|
||||
}
|
||||
|
||||
type EventOnProxyStats struct {
|
||||
SnowflakeEvent
|
||||
ConnectionCount int
|
||||
// Completed successful connections.
|
||||
ConnectionCount int
|
||||
// Connections that failed to establish.
|
||||
FailedConnectionCount uint
|
||||
InboundBytes, OutboundBytes int64
|
||||
InboundUnit, OutboundUnit string
|
||||
SummaryInterval time.Duration
|
||||
}
|
||||
|
||||
func (e EventOnProxyStats) String() string {
|
||||
statString := fmt.Sprintf("In the last %v, there were %v completed connections. Traffic Relayed ↓ %v %v (%.2f %v%s), ↑ %v %v (%.2f %v%s).",
|
||||
e.SummaryInterval.String(), e.ConnectionCount,
|
||||
statString := fmt.Sprintf("In the last %v, there were %v completed successful connections. %v connections failed to establish. Traffic Relayed ↓ %v %v (%.2f %v%s), ↑ %v %v (%.2f %v%s).",
|
||||
e.SummaryInterval.String(), e.ConnectionCount, e.FailedConnectionCount,
|
||||
e.InboundBytes, e.InboundUnit, float64(e.InboundBytes)/e.SummaryInterval.Seconds(), e.InboundUnit, "/s",
|
||||
e.OutboundBytes, e.OutboundUnit, float64(e.OutboundBytes)/e.SummaryInterval.Seconds(), e.OutboundUnit, "/s")
|
||||
return statString
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue