Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering Sentry events #188

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Cody.Core/Cody.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
<Compile Include="Infrastructure\IProgressService.cs" />
<Compile Include="Logging\ISentryLog.cs" />
<Compile Include="Logging\ITestLogger.cs" />
<Compile Include="Logging\SentryExceptionFilter.cs" />
<Compile Include="Logging\SentryLog.cs" />
<Compile Include="Trace\FileTraceListener.cs" />
<Compile Include="Trace\LogioTraceListener.cs" />
Expand Down
1 change: 0 additions & 1 deletion src/Cody.Core/DocumentSync/DocumentSyncCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 0 additions & 32 deletions src/Cody.Core/Logging/SentryExceptionFilter.cs

This file was deleted.

25 changes: 24 additions & 1 deletion src/Cody.Core/Logging/SentryLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
});
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Cody.VisualStudio/Client/AgentClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public async Task<IAgentService> 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()
Expand Down
Loading