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

Report ScanServerEntries duration in CandidateServers notice

Rod Hynes 5 лет назад
Родитель
Сommit
34e59ab0d3
2 измененных файлов с 12 добавлено и 3 удалено
  1. 8 1
      psiphon/controller.go
  2. 4 2
      psiphon/notice.go

+ 8 - 1
psiphon/controller.go

@@ -611,8 +611,14 @@ loop:
 			}
 		}
 
+		startTime := time.Now()
+
 		response.err = ScanServerEntries(callback)
 
+		// Report this duration in CandidateServers as an indication of datastore
+		// performance.
+		duration := time.Since(startTime)
+
 		response.availableEgressRegions = make([]string, 0, len(regions))
 		for region := range regions {
 			response.availableEgressRegions = append(response.availableEgressRegions, region)
@@ -645,7 +651,8 @@ loop:
 				controller.config.EgressRegion,
 				controller.protocolSelectionConstraints,
 				response.initialCandidates,
-				response.candidates)
+				response.candidates,
+				duration)
 
 			NoticeAvailableEgressRegions(
 				response.availableEgressRegions)

+ 4 - 2
psiphon/notice.go

@@ -401,7 +401,8 @@ func NoticeCandidateServers(
 	region string,
 	constraints *protocolSelectionConstraints,
 	initialCount int,
-	count int) {
+	count int,
+	duration time.Duration) {
 
 	singletonNoticeLogger.outputNotice(
 		"CandidateServers", noticeIsDiagnostic,
@@ -411,7 +412,8 @@ func NoticeCandidateServers(
 		"limitTunnelProtocols", constraints.limitProtocols,
 		"replayCandidateCount", constraints.replayCandidateCount,
 		"initialCount", initialCount,
-		"count", count)
+		"count", count,
+		"duration", duration.String())
 }
 
 // NoticeAvailableEgressRegions is what regions are available for egress from.