Skip to content

Commit

Permalink
Fixed head/tail frames uploading decision
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenMatan committed Feb 19, 2024
1 parent 5391766 commit 2a03f0d
Showing 1 changed file with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,24 @@ private static void ProcessException(Exception exception, ErrorOriginKind errorO
var capturedFrames = resultCallStackTree.Frames;
var allFrames = @case.ExceptionId.StackTrace;

var frameIndex = allFrames.Length - 1;
// Upload head frame
var frameIndex = 0;

while (frameIndex < allFrames.Length &&
!allFrames[frameIndex].Method.Equals(capturedFrames[0].MethodInfo.Method))
{
frameIndex += 1;
}

TagAndUpload(rootSpan, $"{debugErrorPrefix}.{allFrames.Length - frameIndex - 1}.", capturedFrames[0]);

// Upload tail frames
frameIndex = allFrames.Length - 1;
var capturedFrameIndex = capturedFrames.Count - 1;
var assignIndex = 0;
var tagged = 0;

// Upload tail frames
while (frameIndex >= 0 && capturedFrameIndex >= 0 && tagged < MaxFramesToCapture)
while (capturedFrameIndex >= 1 && frameIndex >= 0 && tagged < MaxFramesToCapture)
{
var frame = capturedFrames[capturedFrameIndex];

Expand All @@ -188,23 +199,6 @@ private static void ProcessException(Exception exception, ErrorOriginKind errorO
TagAndUpload(rootSpan, prefix, frame);
}

// Upload head frame
if (capturedFrames.Count > MaxFramesToCapture)
{
var frame = capturedFrames[0];

frameIndex = 0;

while (frameIndex < allFrames.Length &&
!allFrames[frameIndex].Method.Equals(frame.MethodInfo.Method))
{
frameIndex += 1;
}

var prefix = $"{debugErrorPrefix}.{allFrames.Length - frameIndex - 1}.";
TagAndUpload(rootSpan, prefix, frame);
}

Log.Information("Reverting an exception case for exception: {Name}, Message: {Message}, StackTrace: {StackTrace}", exception.GetType().Name, exception.Message, exception.StackTrace);

if (trackedExceptionCase.Revert())
Expand Down

0 comments on commit 2a03f0d

Please sign in to comment.