@@ -45,6 +45,7 @@ public sealed partial class LanguageServer : IDisposable {
45
45
46
46
private IServiceContainer _services ;
47
47
private IUIService _ui ;
48
+ private ITelemetryService2 _telemetry ;
48
49
49
50
private JsonRpc _rpc ;
50
51
private JsonSerializer _jsonSerializer ;
@@ -60,10 +61,11 @@ public CancellationToken Start(IServiceContainer services, JsonRpc rpc) {
60
61
_ui = services . GetService < IUIService > ( ) ;
61
62
_rpc = rpc ;
62
63
_jsonSerializer = services . GetService < JsonSerializer > ( ) ;
64
+ _telemetry = services . GetService < ITelemetryService2 > ( ) ;
63
65
64
66
var progress = services . GetService < IProgressService > ( ) ;
65
67
66
- var rpcTraceListener = new TelemetryRpcTraceListener ( services . GetService < ITelemetryService2 > ( ) ) ;
68
+ var rpcTraceListener = new TelemetryRpcTraceListener ( _telemetry ) ;
67
69
_rpc . TraceSource . Listeners . Add ( rpcTraceListener ) ;
68
70
69
71
_server . OnLogMessage += OnLogMessage ;
@@ -72,6 +74,7 @@ public CancellationToken Start(IServiceContainer services, JsonRpc rpc) {
72
74
_server . OnApplyWorkspaceEdit += OnApplyWorkspaceEdit ;
73
75
_server . OnRegisterCapability += OnRegisterCapability ;
74
76
_server . OnUnregisterCapability += OnUnregisterCapability ;
77
+ _server . AnalysisQueue . UnhandledException += OnAnalysisQueueUnhandledException ;
75
78
76
79
_disposables
77
80
. Add ( ( ) => _server . OnLogMessage -= OnLogMessage )
@@ -80,6 +83,7 @@ public CancellationToken Start(IServiceContainer services, JsonRpc rpc) {
80
83
. Add ( ( ) => _server . OnApplyWorkspaceEdit -= OnApplyWorkspaceEdit )
81
84
. Add ( ( ) => _server . OnRegisterCapability -= OnRegisterCapability )
82
85
. Add ( ( ) => _server . OnUnregisterCapability -= OnUnregisterCapability )
86
+ . Add ( ( ) => _server . AnalysisQueue . UnhandledException -= OnAnalysisQueueUnhandledException )
83
87
. Add ( ( ) => _shutdownCts . Cancel ( ) )
84
88
. Add ( _prioritizer )
85
89
. Add ( ( ) => _pathsWatcher ? . Dispose ( ) )
@@ -454,6 +458,16 @@ private void HandlePathWatchChange(JToken section) {
454
458
_searchPaths = _initParams . initializationOptions . searchPaths ;
455
459
}
456
460
461
+ private void OnAnalysisQueueUnhandledException ( object sender , UnhandledExceptionEventArgs e ) {
462
+ if ( ! ( e . ExceptionObject is Exception ex ) ) {
463
+ Debug . Fail ( $ "ExceptionObject was { e . ExceptionObject . GetType ( ) } , not Exception") ;
464
+ return ;
465
+ }
466
+
467
+ var te = Telemetry . CreateEventWithException ( "analysis_queue.unhandled_exception" , ex ) ;
468
+ _telemetry . SendTelemetry ( te ) . DoNotWait ( ) ;
469
+ }
470
+
457
471
private class Prioritizer : IDisposable {
458
472
private const int InitializePriority = 0 ;
459
473
private const int ConfigurationPriority = 1 ;
0 commit comments