sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

Refactor OnEvaluating event hook to avoid delegate allocation

Open jamescrosswell opened this issue 5 months ago • 0 comments

The outer ConfigureScope call no longer allocates a closure, but this OnEvaluating event handler still allocates unconditionally. One solution might be to store KeyValuePairs of the callback and its argument instead of using an event inside a Stack. Perhaps the Stack wouldn't even be necessary when the Sentry.AspNetCore.Grpc integration isn't loaded, as that seems to be the only other place (outside of tests) where this event handler is assigned.

Originally posted by @KnapSac in https://github.com/getsentry/sentry-dotnet/pull/4244#discussion_r2124679960

Worth reading through that whole thread on the other issue before coming up with a solution (and probably worth putting some benchmarks together - possibly some load tests as well).

jamescrosswell avatar Jun 04 '25 23:06 jamescrosswell