MindscapeHQ / raygun4net

Raygun provider for .NET
https://raygun.com
MIT License
125 stars 91 forks source link

Build message before queuing it #540

Closed phillip-haydon closed 3 months ago

phillip-haydon commented 3 months ago

This change is required for updates to Serilog provider where Serilog uses the base implementation of SendInBackground but depends on IRaygunUserProvider to get the user info from HttpContextAccessor.HttpContext

When the build message is sent as a delegate to Enqueue it gets executed out of context and the information is lost.

There is a minor overhead in memory building the message up front but this only occurs when there's a huge number of exceptions being thrown.

sumitramanga commented 3 months ago

How much are we talking in terms of " huge number of exceptions" for the overhead issue?

phillip-haydon commented 3 months ago

How much are we talking in terms of " huge number of exceptions" for the overhead issue?

When we tested it, we chucked it in a loop sending 100k exceptions to see what happened with the memory, it grew a little bit more than if it was delegated, not enough to cause a problem, but just didn't want people to think we were having a memory leak.

This change is more important than ~10mb of data showing up in memory profiling though.

phillip-haydon commented 3 months ago

Possibly fixes #536