Skip to content

Commit

Permalink
chore: improve stack trace logging
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Nov 21, 2022
1 parent df2fbbb commit 24f1816
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Sentry/Extensibility/SentryStackTraceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SentryStackTraceFactory : ISentryStackTraceFactory

var stackTrace = exception is null ? new StackTrace(true) : new StackTrace(exception, true);
var result = SentryDebugStackTrace.Create(_options, stackTrace, isCurrentStackTrace);
_options.LogDebug("Created SentryDebugStackTrace with {0} frames.", result.Frames.Count);
return result.Frames.Count != 0 ? result : null;
}
}
5 changes: 5 additions & 0 deletions src/Sentry/Internal/SentryDebugStackTrace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ internal void MergeDebugImagesInto(SentryEvent @event)
}
_debugImagesMerged = true;

_options.LogDebug("Merging {0} debug images from stacktrace.", _debugImages.Count);
if (_debugImages.Count == 0)
{
return;
Expand Down Expand Up @@ -156,6 +157,7 @@ private IEnumerable<SentryStackFrame> CreateFrames(StackTrace stackTrace, bool i
&& stackFrame.GetMethod() is { } method
&& method.DeclaringType?.AssemblyQualifiedName?.StartsWith("Sentry") == true)
{
_options.LogDebug("Skipping initial stack frame '{0}'", method.Name);
continue;
}

Expand Down Expand Up @@ -379,6 +381,8 @@ private static void DemangleLambdaReturnType(SentryStackFrame frame)
var codeFile = module.FullyQualifiedName;
if (!File.Exists(codeFile))
{
_options.LogDebug("Skipping DebugImage for module '{0}' because CodeFile wasn't found: '{1}'",
module.Name, codeFile);
return null;
}
using var stream = File.OpenRead(codeFile);
Expand Down Expand Up @@ -423,6 +427,7 @@ private static void DemangleLambdaReturnType(SentryStackFrame frame)
// well, we are out of luck :-(
if (debugId == null)
{
_options.LogDebug("Skipping DebugImage for module '{0}' because DebugId couldn't be determined", module.Name);
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Tests/HubTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ public async Task CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEn
});

await Verifier.Verify(worker.Envelopes)
.UniqueForRuntimeAndVersion()
.IgnoreStandardSentryMembers()
.IgnoreMember("Stacktrace")
.IgnoreMember<SentryThread>(_ => _.Name)
.UniqueForRuntimeAndVersion()
.IgnoreInstance<DebugImage>(_ => _.DebugFile.Contains("Xunit.SkippableFact"));
}

Expand Down

0 comments on commit 24f1816

Please sign in to comment.