13
13
// See the Apache Version 2.0 License for specific language governing
14
14
// permissions and limitations under the License.
15
15
16
+ using System ;
16
17
using System . Diagnostics ;
17
18
using Microsoft . Python . Analysis . Analyzer ;
18
19
using Microsoft . Python . Core ;
@@ -29,28 +30,34 @@ private void OnAnalysisComplete(object sender, AnalysisCompleteEventArgs e) {
29
30
return ;
30
31
}
31
32
32
- double privateMB ;
33
- double peakPagedMB ;
34
- double workingMB ;
33
+ try {
34
+ double privateMB ;
35
+ double peakPagedMB ;
36
+ double workingMB ;
35
37
36
- using ( var proc = Process . GetCurrentProcess ( ) ) {
37
- privateMB = proc . PrivateMemorySize64 / 1e+6 ;
38
- peakPagedMB = proc . PeakPagedMemorySize64 / 1e+6 ;
39
- workingMB = proc . WorkingSet64 / 1e+6 ;
40
- }
38
+ using ( var proc = Process . GetCurrentProcess ( ) ) {
39
+ privateMB = proc . PrivateMemorySize64 / 1e+6 ;
40
+ peakPagedMB = proc . PeakPagedMemorySize64 / 1e+6 ;
41
+ workingMB = proc . WorkingSet64 / 1e+6 ;
42
+ }
41
43
42
- var te = new TelemetryEvent {
43
- EventName = "python_language_server/analysis_complete" , // TODO: Move this common prefix into Core.
44
- } ;
44
+ var te = new TelemetryEvent {
45
+ EventName = "python_language_server/analysis_complete" , // TODO: Move this common prefix into Core.
46
+ } ;
45
47
46
- te . Measurements [ "privateMB" ] = privateMB ;
47
- te . Measurements [ "peakPagedMB" ] = peakPagedMB ;
48
- te . Measurements [ "workingMB" ] = workingMB ;
49
- te . Measurements [ "elapsedMs" ] = e . MillisecondsElapsed ;
50
- te . Measurements [ "moduleCount" ] = e . ModuleCount ;
51
- te . Measurements [ "rdtCount" ] = _rdt . DocumentCount ;
48
+ te . Measurements [ "privateMB" ] = privateMB ;
49
+ te . Measurements [ "peakPagedMB" ] = peakPagedMB ;
50
+ te . Measurements [ "workingMB" ] = workingMB ;
51
+ te . Measurements [ "elapsedMs" ] = e . MillisecondsElapsed ;
52
+ te . Measurements [ "moduleCount" ] = e . ModuleCount ;
53
+ te . Measurements [ "rdtCount" ] = _rdt . DocumentCount ;
52
54
53
- telemetry . SendTelemetryAsync ( te ) . DoNotWait ( ) ;
55
+ telemetry . SendTelemetryAsync ( te ) . DoNotWait ( ) ;
56
+ } catch ( Exception ex ) when ( ! ex . IsCriticalException ( ) ) {
57
+ // Workaround for https://github.com/microsoft/python-language-server/issues/1820
58
+ // On some systems random DLL may get missing or otherwise not installed
59
+ // and we don't want to crash b/c of telemetry.
60
+ }
54
61
}
55
62
}
56
63
}
0 commit comments