Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions ExtractorUtils/Unstable/Tasks/CheckInWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,37 @@ private async Task ReportCheckIn(CancellationToken token)
}
else
{
newErrors = _errors.Values.ToList();
newErrors = new List<ErrorWithTask>(_errors.Values);
foreach (var err in _errors.Values)
{
// Modifying err since it's an object reference in the dictionary, so changes will be reflected when we write the check-in,
// but we want to log the full error before truncating.
_logger.LogInformation("Error: {ExternalId}, Level: {Level}, Description: {Description}, Details: {Details}, Task: {Task}, StartTime: {StartTime}, EndTime: {EndTime}",
err.ExternalId, err.Level, err.Description, err.Details, err.Task, err.StartTime, err.EndTime);
if (err.Description != null && err.Description.Length > 5000)
{
_logger.LogWarning("Truncating description for error {ExternalId} to 5,000 characters. Original length was {OriginalLength}", err.ExternalId, err.Description.Length);
err.Description = err.Description.Substring(0, 5000);
}
else if (err.Details != null && err.Details.Length > 5000)
{
_logger.LogWarning("Error {ExternalId} has details exceeding 5,000 characters, truncating. Original length was {OriginalLength}", err.ExternalId, err.Details.Length);
err.Details = err.Details.Substring(0, 5000);
}
}
_errors.Clear();
taskUpdates = _taskUpdates;
_taskUpdates = new List<TaskUpdate>();
}
}

newErrors.Sort((a, b) => (a.EndTime ?? a.StartTime).CompareTo(b.EndTime ?? b.StartTime));
newErrors.Sort((a, b) =>
{
long? aTime = a.EndTime ?? a.StartTime;
long? bTime = b.EndTime ?? b.StartTime;
// Handle null timestamps by treating them as 0 (earliest possible time)
return (aTime ?? 0).CompareTo(bTime ?? 0);
});
taskUpdates.Sort((a, b) => a.Timestamp.CompareTo(b.Timestamp));

while (!token.IsCancellationRequested)
Expand Down