@@ -137,20 +137,25 @@ private async Task StartAsync() {
137137 stopWatch . Stop ( ) ;
138138
139139 bool isCanceled ;
140+ bool isFinal ;
140141 lock ( _syncObj ) {
141142 isCanceled = _isCanceled ;
142143 _state = State . Completed ;
144+ isFinal = _walker . MissingKeys . Count == 0 && ! isCanceled && remaining == 0 ;
143145 _walker = null ;
144146 }
145147
146148 if ( ! isCanceled ) {
147149 _progress . ReportRemaining ( remaining ) ;
150+ if ( isFinal ) {
151+ ActivityTracker . EndTracking ( ) ;
152+ ( _analyzer as PythonAnalyzer ) ? . RaiseAnalysisComplete ( ActivityTracker . ModuleCount , ActivityTracker . MillisecondsElapsed ) ;
153+ _log ? . Log ( TraceEventType . Verbose , $ "Analysis complete: { ActivityTracker . ModuleCount } modules in { ActivityTracker . MillisecondsElapsed } ms.") ;
154+ }
148155 }
149156 }
150157
151158 var elapsed = stopWatch . Elapsed . TotalMilliseconds ;
152-
153- SendTelemetry ( _telemetry , elapsed , originalRemaining , remaining , Version ) ;
154159 LogResults ( _log , elapsed , originalRemaining , remaining , Version ) ;
155160 ForceGCIfNeeded ( originalRemaining , remaining ) ;
156161 }
@@ -162,38 +167,6 @@ private static void ForceGCIfNeeded(int originalRemaining, int remaining) {
162167 }
163168 }
164169
165- private static void SendTelemetry ( ITelemetryService telemetry , double elapsed , int originalRemaining , int remaining , int version ) {
166- if ( telemetry == null ) {
167- return ;
168- }
169-
170- if ( remaining != 0 || originalRemaining < 100 ) {
171- return ;
172- }
173-
174- double privateMB ;
175- double peakPagedMB ;
176- double workingMB ;
177-
178- using ( var proc = Process . GetCurrentProcess ( ) ) {
179- privateMB = proc . PrivateMemorySize64 / 1e+6 ;
180- peakPagedMB = proc . PeakPagedMemorySize64 / 1e+6 ;
181- workingMB = proc . WorkingSet64 / 1e+6 ;
182- }
183-
184- var e = new TelemetryEvent {
185- EventName = "python_language_server/analysis_complete" , // TODO: Move this common prefix into Core.
186- } ;
187-
188- e . Measurements [ "privateMB" ] = privateMB ;
189- e . Measurements [ "peakPagedMB" ] = peakPagedMB ;
190- e . Measurements [ "workingMB" ] = workingMB ;
191- e . Measurements [ "elapsedMs" ] = elapsed ;
192- e . Measurements [ "entries" ] = originalRemaining ;
193- e . Measurements [ "version" ] = version ;
194-
195- telemetry . SendTelemetryAsync ( e ) . DoNotWait ( ) ;
196- }
197170
198171 private static void LogResults ( ILogger logger , double elapsed , int originalRemaining , int remaining , int version ) {
199172 if ( logger == null ) {
@@ -226,6 +199,8 @@ private async Task<int> AnalyzeAffectedEntriesAsync(Stopwatch stopWatch) {
226199 continue ;
227200 }
228201
202+ ActivityTracker . OnEnqueueModule ( node . Value . Module . FilePath ) ;
203+
229204 if ( Interlocked . Increment ( ref _runningTasks ) >= _maxTaskRunning || _walker . Remaining == 1 ) {
230205 Analyze ( node , null , stopWatch ) ;
231206 } else {
@@ -241,7 +216,7 @@ private async Task<int> AnalyzeAffectedEntriesAsync(Stopwatch stopWatch) {
241216
242217 if ( _walker . MissingKeys . Count == 0 || _walker . MissingKeys . All ( k => k . IsTypeshed ) ) {
243218 Interlocked . Exchange ( ref _runningTasks , 0 ) ;
244-
219+
245220 if ( ! isCanceled ) {
246221 _analysisCompleteEvent . Set ( ) ;
247222 }
@@ -279,6 +254,7 @@ private void Analyze(IDependencyChainNode<PythonAnalyzerEntry> node, AsyncCountd
279254 var startTime = stopWatch . Elapsed ;
280255 AnalyzeEntry ( entry , module , ast , _walker . Version ) ;
281256 node . Commit ( ) ;
257+ ActivityTracker . OnModuleAnalysisComplete ( node . Value . Module . FilePath ) ;
282258
283259 LogCompleted ( module , stopWatch , startTime ) ;
284260 } catch ( OperationCanceledException oce ) {
0 commit comments