Skip to content

Commit

Permalink
Prevent collected exceptions from being dropped due to null event val…
Browse files Browse the repository at this point in the history
…ues (#7301)
  • Loading branch information
schmittjoseph committed Sep 10, 2024
1 parent 5a48325 commit 08eed9b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public void ExceptionGroup(
public void ExceptionInstance(
ulong ExceptionId,
ulong ExceptionGroupId,
string? ExceptionMessage,
string ExceptionMessage,
ulong[] StackFrameIds,
DateTime Timestamp,
ulong[] InnerExceptionIds,
string? ActivityId,
string ActivityId,
ActivityIdFormat ActivityIdFormat)
{
Span<EventData> data = stackalloc EventData[8];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Invoke(Exception exception, ExceptionPipelineExceptionContext contex
frameIds,
context.Timestamp,
GetInnerExceptionsIds(exception),
context.ActivityId,
context.ActivityId ?? string.Empty,
context.ActivityIdFormat
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal interface IExceptionInstance

ulong[] InnerExceptionIds { get; }

public string? ActivityId { get; }
public string ActivityId { get; }

public ActivityIdFormat ActivityIdFormat { get; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void ExceptionsEventSource_WriteException_LevelTooHigh()
using ExceptionsEventListener listener = new();
listener.EnableEvents(source, EventLevel.Warning);

source.ExceptionInstance(5, 7, ObjectDisposedExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), null, ActivityIdFormat.Unknown);
source.ExceptionInstance(5, 7, ObjectDisposedExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), string.Empty, ActivityIdFormat.Unknown);

Assert.Empty(listener.Exceptions);
}
Expand All @@ -120,7 +120,7 @@ public void ExceptionsEventSource_WriteException_NotEnabled()

using ExceptionsEventListener listener = new();

source.ExceptionInstance(7, 9, OperationCancelledExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), null, ActivityIdFormat.Unknown);
source.ExceptionInstance(7, 9, OperationCancelledExceptionMessage, Array.Empty<ulong>(), DateTime.UtcNow, Array.Empty<ulong>(), string.Empty, ActivityIdFormat.Unknown);

Assert.Empty(listener.Exceptions);
}
Expand Down

0 comments on commit 08eed9b

Please sign in to comment.