Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ThrottledBackgroundMessageProcessor to dynamically create task workers #542

Merged
merged 9 commits into from
Aug 25, 2024
3 changes: 3 additions & 0 deletions CHANGE-LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### v11.0.4
- Fix issue with `RaygunClientBase` where `SendInBackground` deferred building the message until late, losing HttpContext
- See: https://github.com/MindscapeHQ/raygun4net/pull/540
- Fix issue with `ThrottledBackgroundMessageProcessor` where it would hold up to 8 task threads even when idle
- Task Workers are now created as needed and are disposed when not needed or idle
- See: https://github.com/MindscapeHQ/raygun4net/pull/542

### v11.0.3
- Update `RaygunHttpModule` (Raygun4Net ASP.NET Framework) to use a singleton `RaygunClient` instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ protected virtual async Task ProcessOfflineCrashReports()
}
catch (Exception ex)
{
Debug.WriteLine($"Exception sending offline error [{crashReport.Id}]: {ex}");
Trace.WriteLine($"Exception sending offline error [{crashReport.Id}]: {ex}");
throw;
}
}
}
catch (Exception ex)
{
Debug.WriteLine($"Exception sending offline errors: {ex}");
Trace.WriteLine($"Exception sending offline errors: {ex}");
}
}

Expand Down
2 changes: 1 addition & 1 deletion Mindscape.Raygun4Net.NetCore.Common/RaygunClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected RaygunClientBase(RaygunSettingsBase settings, HttpClient client, IRayg
{
_client = client ?? DefaultClient;
_settings = settings;
_backgroundMessageProcessor = new ThrottledBackgroundMessageProcessor(settings.BackgroundMessageQueueMax, _settings.BackgroundMessageWorkerCount, Send);
_backgroundMessageProcessor = new ThrottledBackgroundMessageProcessor(settings.BackgroundMessageQueueMax, _settings.BackgroundMessageWorkerCount, _settings.BackgroundMessageWorkerBreakpoint, Send);
_userProvider = userProvider;

_wrapperExceptions.Add(typeof(TargetInvocationException));
Expand Down
14 changes: 11 additions & 3 deletions Mindscape.Raygun4Net.NetCore.Common/RaygunSettingsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public RaygunSettingsBase()
public string ApplicationVersion { get; set; }

/// <summary>
/// If set to true will automatically setup handlers to catch Unhandled Exceptions
/// If set to true will automatically set up handlers to catch Unhandled Exceptions
/// </summary>
/// <remarks>
/// Currently defaults to false. This may be change in future releases.
/// Currently defaults to false. This may be changed in future releases.
/// </remarks>
public bool CatchUnhandledExceptions { get; set; } = false;

Expand All @@ -45,13 +45,21 @@ public RaygunSettingsBase()
public int BackgroundMessageQueueMax { get; } = ushort.MaxValue;

/// <summary>
/// Controls the number of background threads used to process the raygun message queue
/// Controls the maximum number of background threads used to process the raygun message queue
/// </summary>
/// <remarks>
/// Defaults to Environment.ProcessorCount * 2 &gt;= 8 ? 8 : Environment.ProcessorCount * 2
/// </remarks>
public int BackgroundMessageWorkerCount { get; set; } = Environment.ProcessorCount * 2 >= 8 ? 8 : Environment.ProcessorCount * 2;

/// <summary>
/// Used to determine how many messages are in the queue before the background processor will add another worker to help process the queue.
/// </summary>
/// <remarks>
/// Defaults to 25, workers will be added for every 25 messages in the queue, until the BackgroundMessageWorkerCount is reached.
/// </remarks>
public int BackgroundMessageWorkerBreakpoint { get; set; } = 25;

/// <summary>
/// A list of Environment Variables to include with the message.
/// </summary>
Expand Down
Loading