Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 60f5779

Browse files
author
Mikhail Arkhipov
committed
Handle non-critical exceptions in telemetry (#1840)
* Remove stale reference * Don't suppress LHS diagnostics on augmented assign * Revert "Don't suppress LHS diagnostics on augmented assign" This reverts commit 6109ac7. * Escape [ and ] * PR feedback * Handle non-critical issues in telemetry (cherry picked from commit 480fd6d)
1 parent 7ff82a4 commit 60f5779

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

src/LanguageServer/Impl/Implementation/Server.Telemetry.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// See the Apache Version 2.0 License for specific language governing
1414
// permissions and limitations under the License.
1515

16+
using System;
1617
using System.Diagnostics;
1718
using Microsoft.Python.Analysis.Analyzer;
1819
using Microsoft.Python.Core;
@@ -29,28 +30,34 @@ private void OnAnalysisComplete(object sender, AnalysisCompleteEventArgs e) {
2930
return;
3031
}
3132

32-
double privateMB;
33-
double peakPagedMB;
34-
double workingMB;
33+
try {
34+
double privateMB;
35+
double peakPagedMB;
36+
double workingMB;
3537

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+
}
4143

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+
};
4547

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;
5254

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+
}
5461
}
5562
}
5663
}

0 commit comments

Comments
 (0)