Skip to content

Commit

Permalink
Improve telemetry tracking by avoiding null trace messages
Browse files Browse the repository at this point in the history
The changes in the AppInsightsRemoteLogger class's TrackTrace method ensure that no null or empty messages are sent to the telemetryClient. This prevents potential errors and useless logs.

This modification is made after identifying cases of null or empty logs causing issues in the telemetry data. The updated function now checks if the message is null or whitespace before sending it to the telemetryClient.
  • Loading branch information
christianhelle committed Nov 2, 2023
1 parent 6bda157 commit 4474352
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public void WriteLine(object data)
{
if (TestingUtility.IsRunningFromUnitTest || Debugger.IsAttached || telemetryClient == null)
return;
telemetryClient.TrackTrace(data.ToString());
var message = data?.ToString();
if (string.IsNullOrWhiteSpace(message))
return;
telemetryClient.TrackTrace(message);
telemetryClient.Flush();
}
}
Expand Down

0 comments on commit 4474352

Please sign in to comment.