Przeglądaj źródła

Pre-calculate a total-tunneled-bytes field

Rod Hynes 8 lat temu
rodzic
commit
75d91d63ec
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      psiphon/server/tunnelServer.go

+ 7 - 0
psiphon/server/tunnelServer.go

@@ -1693,6 +1693,13 @@ func (sshClient *sshClient) logTunnel(additionalMetrics LogFields) {
 	logFields["peak_concurrent_port_forward_count_udp"] = sshClient.udpTrafficState.peakConcurrentPortForwardCount
 	logFields["total_port_forward_count_udp"] = sshClient.udpTrafficState.totalPortForwardCount
 
+	// Pre-calculate a total-tunneled-bytes field. This total is used
+	// extensively in analytics and is more performant when pre-calculated.
+	logFields["bytes"] = sshClient.tcpTrafficState.bytesUp +
+		sshClient.tcpTrafficState.bytesDown +
+		sshClient.udpTrafficState.bytesUp +
+		sshClient.udpTrafficState.bytesDown
+
 	// Merge in additional metrics from the optional metrics source
 	if additionalMetrics != nil {
 		for name, value := range additionalMetrics {