Просмотр исходного кода

Use LogRawFieldsWithTimestamp for load logs; test load logs

Rod Hynes 9 лет назад
Родитель
Сommit
4bc87700d1
2 измененных файлов с 6 добавлено и 1 удалено
  1. 4 0
      psiphon/server/server_test.go
  2. 2 1
      psiphon/server/services.go

+ 4 - 0
psiphon/server/server_test.go

@@ -169,6 +169,10 @@ func runServer(t *testing.T, runConfig *runServerConfig) {
 	serverConfig.(map[string]interface{})["TrafficRulesFilename"] = ""
 	serverConfig.(map[string]interface{})["LogLevel"] = "debug"
 
+	// 1 second is the minimum period; should be small enough to emit a log during the
+	// test run, but not guaranteed
+	serverConfig.(map[string]interface{})["LoadMonitorPeriodSeconds"] = 1
+
 	serverConfigJSON, _ = json.Marshal(serverConfig)
 
 	// run server

+ 2 - 1
psiphon/server/services.go

@@ -153,6 +153,7 @@ func logServerLoad(server *TunnelServer) {
 	var memStats runtime.MemStats
 	runtime.ReadMemStats(&memStats)
 	fields := LogFields{
+		"event_type":   "server_load",
 		"BuildRev":     common.GetBuildInfo().BuildRev,
 		"HostID":       server.sshServer.support.Config.HostID,
 		"NumGoroutine": runtime.NumGoroutine(),
@@ -172,7 +173,7 @@ func logServerLoad(server *TunnelServer) {
 		fields[tunnelProtocol] = stats
 	}
 
-	log.WithContextFields(fields).Info("load")
+	log.LogRawFieldsWithTimestamp(fields)
 }
 
 // SupportServices carries common and shared data components