Skip to content

Commit

Permalink
Fixed a small bug slipped in as part of the nullability fixes done in…
Browse files Browse the repository at this point in the history
… PR #5163 + added diagnosting tags to Exception Debugging when the log level is set to Debug
  • Loading branch information
GreenMatan committed Mar 20, 2024
1 parent abf716f commit d474d46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public bool Process<TCapture>(ref CaptureInfo<TCapture> info, IDebuggerSnapshotC
}

var exception = info.Value as Exception;
snapshotCreator.TrackedStackFrameNode.LeavingException = exception;
snapshotCreator.LeaveHash = shadowStack.CurrentStackFrameNode?.LeaveSequenceHash ?? Fnv1aHash.FnvOffsetBias;

var leavingExceptionType = info.Value.GetType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,14 @@ private static void TagAndUpload(Span span, string tagPrefix, ExceptionStackNode
span.Tags.SetTag(tagPrefix + "frame_data.class_name", method.DeclaringType?.Name);
span.Tags.SetTag(tagPrefix + "snapshot_id", snapshotId);

tagPrefix = tagPrefix.Replace("_", string.Empty);
if (Log.IsEnabled(LogEventLevel.Debug))
{
tagPrefix = tagPrefix.Replace("_", string.Empty);

span.Tags.SetTag(tagPrefix + "frame_data.function", method.Name);
span.Tags.SetTag(tagPrefix + "frame_data.class_name", method.DeclaringType?.Name);
span.Tags.SetTag(tagPrefix + "snapshot_id", snapshotId);
span.Tags.SetTag(tagPrefix + "frame_data.function", method.Name);
span.Tags.SetTag(tagPrefix + "frame_data.class_name", method.DeclaringType?.Name);
span.Tags.SetTag(tagPrefix + "snapshot_id", snapshotId);
}

ExceptionDebugging.AddSnapshot(probeId, snapshot);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public int SequenceHash

public TrackedStackFrameNode? Parent => _parent;

public Exception? LeavingException { get; private set; }
public Exception? LeavingException { get; set; }

public string Snapshot
{
Expand Down Expand Up @@ -180,9 +180,9 @@ internal void AddScopeMember<T>(string name, Type type, T value, ScopeMemberKind
Members.AddMember(new ScopeMember(name, type, value, memberKind));
}

private IEnumerable<Exception> FlattenException(Exception exception)
private IEnumerable<Exception?> FlattenException(Exception? exception)
{
var exceptionList = new Stack<Exception>();
var exceptionList = new Stack<Exception?>();

exceptionList.Push(exception);

Expand Down Expand Up @@ -334,14 +334,9 @@ private void ClearNonRelevantChildNodes()
}
}

public bool HasChildException(Exception exception)
public bool HasChildException(Exception? exception)
{
if (LeavingException == null)
{
return false;
}

if (LeavingException == exception || LeavingException == exception.InnerException)
if (LeavingException == exception || LeavingException == exception?.InnerException)
{
return true;
}
Expand Down

0 comments on commit d474d46

Please sign in to comment.