diff --git a/src/Cody.Core/Cody.Core.csproj b/src/Cody.Core/Cody.Core.csproj index 42cddacc..545e0acb 100644 --- a/src/Cody.Core/Cody.Core.csproj +++ b/src/Cody.Core/Cody.Core.csproj @@ -91,7 +91,6 @@ - diff --git a/src/Cody.Core/DocumentSync/DocumentSyncCallback.cs b/src/Cody.Core/DocumentSync/DocumentSyncCallback.cs index 7f6ed6fc..97e5c02e 100644 --- a/src/Cody.Core/DocumentSync/DocumentSyncCallback.cs +++ b/src/Cody.Core/DocumentSync/DocumentSyncCallback.cs @@ -106,7 +106,6 @@ public void OnFocus(string fullPath) { trace.TraceEvent("DidFocus", "{0}", fullPath); agentService.DidFocus(new CodyFilePath { Uri = ToUri(fullPath) }); - } public void OnOpened(string fullPath, string content, DocumentRange visibleRange, DocumentRange selection) diff --git a/src/Cody.Core/Logging/SentryExceptionFilter.cs b/src/Cody.Core/Logging/SentryExceptionFilter.cs deleted file mode 100644 index deeb7c0a..00000000 --- a/src/Cody.Core/Logging/SentryExceptionFilter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Sentry.Extensibility; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Cody.Core.Logging -{ - public class SentryExceptionFilter : IExceptionFilter - { - public bool Filter(Exception ex) - { - //https://sourcegraph.sentry.io/issues/6123815161 - if (ex is AggregateException && - ex.InnerException != null && - ex.InnerException is TimeoutException && - ex.InnerException.TargetSite != null && - ex.InnerException.TargetSite.DeclaringType.Name == "TplExtensions" && - ex.InnerException.TargetSite?.Name == "WithTimeout") return false; - - //https://sourcegraph.sentry.io/issues/6152558932 - if(ex.TargetSite.DeclaringType.Assembly.FullName.StartsWith("JetBrains") || - ex.InnerException != null && ex.InnerException.TargetSite.DeclaringType.Assembly.FullName.StartsWith("JetBrains")) return false; - - //https://sourcegraph.sentry.io/issues/6115819359 - if (ex.GetType().Name.StartsWith("JetBrains")) return false; - - return true; - } - } -} diff --git a/src/Cody.Core/Logging/SentryLog.cs b/src/Cody.Core/Logging/SentryLog.cs index 9ad165bb..b1652631 100644 --- a/src/Cody.Core/Logging/SentryLog.cs +++ b/src/Cody.Core/Logging/SentryLog.cs @@ -2,12 +2,15 @@ using Sentry; using System; using System.Diagnostics; +using System.Linq; using System.Reflection; namespace Cody.Core.Logging { public class SentryLog : ISentryLog { + public const string CodyAssemblyPrefix = "Cody."; + public void Error(Exception exception) { SentrySdk.CaptureException(exception); @@ -30,9 +33,29 @@ public static void Initialize() { options.Dsn = "https://d129345ba8e1848a01435eb2596ca899@o19358.ingest.us.sentry.io/4508375896752129"; options.IsGlobalModeEnabled = true; + options.MaxBreadcrumbs = 10; options.Environment = env; options.Release = "cody-vs@" + version.ToString(); - options.AddExceptionFilter(new SentryExceptionFilter()); + options.SetBeforeSend(se => + { + if (se.Exception?.Source?.StartsWith(CodyAssemblyPrefix) ?? false) return se; + if (se.Exception?.InnerException?.Source?.StartsWith(CodyAssemblyPrefix) ?? false) return se; + if (se.SentryExceptions == null) return se; + + foreach(var ex in se.SentryExceptions) + { + if (ex.Module?.StartsWith(CodyAssemblyPrefix) ?? false) return se; + if (ex.Stacktrace != null) + { + foreach (var frame in ex.Stacktrace.Frames) + { + if (frame.Package?.StartsWith(CodyAssemblyPrefix) ?? false) return se; + } + } + } + + return null; + }); }); } } diff --git a/src/Cody.VisualStudio/Client/AgentClient.cs b/src/Cody.VisualStudio/Client/AgentClient.cs index 0d0cb8b0..8498b340 100644 --- a/src/Cody.VisualStudio/Client/AgentClient.cs +++ b/src/Cody.VisualStudio/Client/AgentClient.cs @@ -76,7 +76,10 @@ public async Task Initialize(ClientInfo clientInfo) private void OnDisconnected(object sender, JsonRpcDisconnectedEventArgs e) { - log.Error($"Agent disconnected due to {e.Description} (reason: {e.Reason})", e.Exception); + if(e.Exception != null) + log.Error($"Agent disconnected due to {e.Description} (reason: {e.Reason})", e.Exception); + else + log.Info($"Agent disconnected due to {e.Description} (reason: {e.Reason})"); } private void CreateAgentService()